Setting php.ini Location In Apache

After installing PHP on Apache you can use the php.ini file to set various different options to do with PHP. When Apache starts it uses what is contained in this file to set up and run PHP.

On both Windows, Unix and Linux systems Apache will look in a number of default locations for the php.ini file before giving up. You can explicitly tell Apache 2.x where to look for the file by using the PHPIniDir directive in the http.conf file.

# This is the directory containing php.ini
PHPIniDir "/usr/local/apache/conf"

For Apache 1.3.x this can be set using the SetEnv PHPRC directive.

# specify the directory where php.ini is
SetEnv PHPRC /usr/local/apache/conf

This not only speeds up the time taken for Apache to start, but will also allow you to make sure that the php.ini file you are using is the one you are editing.

You can find the current location of the php.ini file by using the phpinfo() function.



Add new comment

The content of this field is kept private and will not be shown publicly.
3 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.