I found this page: http://www.php.net/manual/en/configuration.file.php. On my OS: Fedora 17, Apache 2.2,PHP 5.4 I searched for PHPIniDir in the httpd.conf file. This configuration does not exists.

How does Apache knows where is the php.ini then ? ( /etc/php.ini)

  • why the downvotes ?
    – johnlemon
    Feb 1 '13 at 21:46

Compile time defaults exist as a fail-safe when certain directives are not specified. In this case the PHP module "knows" where to look for php.ini if no directive is found because it is programmed and compiled in such a way.

  • so it will look directly for /etc/php.ini ?
    – johnlemon
    Feb 1 '13 at 21:51
  • Most likely. It is a compile time option. strings libphp5.so | grep \/etc/ will give you hints about the basedir where it expects to find php.ini in.
    – adamo
    Feb 1 '13 at 22:04
  • found it, perfect
    – johnlemon
    Feb 1 '13 at 22:06

It is php that actually knows where the the php.ini file. This information is most likely incorporated into the PHP Apache module which either is generated by the PHP release or the PHP package is used during apache compilation.


I had a Apache and PHP installed on one of the server. This was installed by the previous sys admin. Both the Apache and PHP was complied from the source. In addition to this there was a default PHP installed. So to know which PHP is used by the Apache. I run the below command

<Install Dir of PHP>/bin/php -i | grep apxs

This gave me the path to apache apxs


This gave me info on which Apache is being used by this php. This path and the apache currently running were the same. The default php gave error when i typed

#php -i | grep apxs 

Failed loading opcache.so:  opcache.so: cannot open shared object file: No    such file or directory PHP Warning:  PHP Startup: Unable to load dynamic library     '<PHP_HOME>/lib/php/extensions/debug-non-zts-20121212/memcached.so' - <PHP_HOME>/lib/php/extensions/debug-non-zts-20121212/memcached.so: undefined symbol: OnUpdateLongGEZero in Unknown on line 0

So in this way i was able to figure out the php used by Apache. APACHE_HOME/modules/ directory has all the modules, libphp5.so was already present in APACHE_HOME/modules/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.