How to find your php.ini file
•
2 min read
What is the php.ini
file?
PHP uses an INI file for all of it's configuration. It gets loaded when PHP starts up and is used to configure extensions and various PHP features.
How you locate your php.ini
file all depends on what sort of access you have to your server. I'll detail a couple of different methods below.
Command-line access
If you have access to php
through the command-line (inside of your terminal - maybe via SSH), you can find the php.ini
file quite quickly.
- Open your terminal locally or connected to your server via SSH.
- Run the
php --ini
command. - Locate the path to the
php.ini
file in the output.
% php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.2
Loaded Configuration File: /opt/homebrew/etc/php/8.2/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.2/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/8.2/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.2/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini
phpinfo()
If you can load a PHP script in the browser, you can use the phpinfo()
function to output all of PHP's configuration values and find the path to the php.ini
file.
Put the following snippet of code into a PHP file and load the file in your browser.
<?php
phpinfo();