Where is php.ini file?
This is a question I have been asked a few times recently. Depending on what system you are running, php.ini could have different locations. But where is php.ini
Firstly, it’s not hidden, it’s a configuration script which determines the settings of your PHP installation. There are few ways to find where the php.ini file.
Find it with a PHP script
The safest way to know it, is through the following script:
<?php phpinfo(); ?>
Once you run the script in your favourite browser, the function phpinfo
() will output what you see in the image below.
Where is php.ini? There it is!
You can find much more details with this function, but in order to locate php.ini, we need to focus only on the field “Loaded Configuration File”. In this example (running Mac OSX 10.6), php.ini is located in /private/etc/php.ini
Find it with BASH script
Another pretty safe way to locate your php configuration file (assuming you are running a UNIX system), is with the following BASH command:
find / -name 'php.ini' 2> /dev/null
This command will search for php.ini file in the whole disk, redirecting any error to null. If you suspect your php.ini file is under the directory /etc/, you can substitute “/” for “/etc/”. The problem with this command, is that you might find multiple php.ini files, and do not really know which one is the active one.
Guess where it is
The location of the file php.ini depends on the installation of PHP. Each distribution goes their way, but there are few common patterns:
||/etc/php.ini /usr/bin/php5/bin/php.ini /etc/php/php.ini /etc/php5/apache2/php.ini
|Windows (with XAMPP installed)
I hope you have found where php.ini is located!