I am running Apache2 on a Mac OS X (10.5). I just compiled PHP 5.2.8 and finally got pdo-mysql
working (or so I think).
This terminal command:
php --version
is showing 5.2.8 and I have the right modules installed.
But, when I do a phpinfo()
, Apache dumps out PHP 5.2.6 (my earlier version, without pdo_mysql
).
How do I tell Apache which PHP to load? The httpd.conf
has the line:
LoadModule php5_module libexec/apache2/libphp5.so
But, I don't know what or where that is.
Is that what I have to change?
I think all these answers aren't really answering the question. The root level can be determined by running the command
httpd -V
. This will show you what options the Apache daemon was built with at compile time. This is what controls wherehttpd
determines where to look for it's config. files and .so modules by default.For example:
The key line in that output is the
HTTPD_ROOT
. That defines where Apache'sROOT
directory is to start,/etc/httpd
in my case, when looking for config. files and modules.NOTE: This
ROOT
is not the same thing asDocumentRoot
. ThisROOT
is specific to how thehttpd
daemon was compiled, theDocumentRoot
is for specifying where thehttpd
daemon should start looking for actual web content (.html files and such).For my
httpd.conf
file I have the following Load lines:Given this the full path to your modules would be, for example:
This is from a CentOS 5.x system but the technique is still apt.
BTW, it can get a little confusing because in CentOS' case the files are organized physically here:
...and then accessible to the Apache daemon,
httpd
, through this path:The
modules
link connects/etc/httpd
-->/usr/lib/httpd/modules
.You can find files on your system with the
locate
command:It will print the full paths of all files with that name. I have one at
/usr/libexec/apache2/libphp5.so
.The parent directory of modules loaded in httpd.conf (such as:
libexec/apache2/libphp5.so
) is defined by theServerRoot
directive which by default is typically set to/usr
. I wouldn't recommend changing this but it may be useful for someone to know just where exactly that path is defined.Apache's website says the following about ServerRoot:
additionally the default httpd.conf file comments read:
ServerRoot: The top of the directory tree under which the server's configuration, error, and log files are kept.
Apache should be looking for modules in "/usr/libexec/httpd/". In there you'll find either a file or symlink called "libphp5.so". If it's a symlink, you'll need to relink to the new 5.2.8 libphp5.so, otherwise just copy the 5.2.8 libphp5.so to "/usr/libexec/httpd/" and restart apache with "sudo apachectl restart".
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
This gave me the path to apache apxs
This gave me info on which Apache is being used by this php. The default php gave error when i typed
So in this way i was able to figure out the php used by Apache.