Where is php.ini on Linux Windows Mac OS X

Depending on what system you are running, php.ini could have different locations. But where is php.ini hidden? Linux Windows Mac OS X

Find php.ini

There are few ways to know where is 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 the what you see in the image.

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:

OSPath
 Linux /etc/php.ini
/usr/bin/php5/bin/php.ini
/etc/php/php.ini
/etc/php5/apache2/php.ini
Mac OSX  /private/etc/php.ini
Windows (with XAMPP installed)  C:/xampp/php/php.ini

I hope you have found where php.ini is located!

 

Visit sunny St. George, Utah, USA