Setting php.ini Location In Apache

15th January 2008 - 2 minutes read time

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.

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

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

  1. # specify the directory where php.ini is
  2. 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.

  1. <?php
  2. phpinfo();
  3. ?>


Add new comment

The content of this field is kept private and will not be shown publicly.