A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow do I tell Apache which PHP to use? - page 1
User InfoPosts
How do I tell Apache which PHP to use?#1
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). My command line "php --version" is showing 5.2.8 and I have the right modules installed. But, when 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?

posted date: 2008-12-22 18:15:00


Re: How do I tell Apache which PHP to use?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-22 18:15:01


Re: How do I tell Apache which PHP to use?#3
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".

posted date: 2008-12-22 19:11:00


Re: How do I tell Apache which PHP to use?#4
You can find files on your system with the locate command:# locate libphp5.soIt will print the full paths of all files with that name. I have one at /usr/libexec/apache2/libphp5.so.

posted date: 2008-12-22 19:14:00


Re: How do I tell Apache which PHP to use?#5
When you compiled php did you use make install? If you did find the path that it installed your module to and change your apache config to point to it. Mac has it's own version of apache and php5 already installed which is why you are seeing a different version.

posted date: 2008-12-22 19:25:00


Re: How do I tell Apache which PHP to use?#6
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 where httpd determines where to look for it's config. files and .so modules by default.For example:% httpd -VServer version: Apache/2.2.17 (Unix)Server built: Dec 17 2010 11:58:24Server's Module Magic Number: 20051115:25Server loaded: APR 1.3.12, APR-Util 1.3.9Compiled using: APR 1.3.12, APR-Util 1.3.9Architecture: 32-bitServer MPM: Prefork threaded: no forked: yes (variable process count)Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"The key line in that output is the HTTPD_ROOT. That defines where Apache's ROOT directory is to start, /etc/httpd in my case, when looking for config. files and modules. NOTE: This ROOT is not the same thing as DocumentRoot. This ROOT is specific to how the httpd daemon was compiled, the DocumentRoot is for specifying where the httpd daemon should start looking for actual web content (.html files and such).For my httpd.conf file I have the following Load lines:LoadModule auth_basic_module modules/mod_auth_basic.soLoadModule auth_digest_module modules/mod_auth_digest.soLoadModule authn_file_module modules/mod_authn_file.soGiven this the full path to your modules would be, for example:/etc/httpd/modules/mod_auth_basic.soThis 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:% ls /usr/lib/httpd/modules/libphp5.so mod_authnz_ldap.so mod_dav_fs.so mod_headers.so mod_perl.so mod_speling.so...and then accessible to the Apache daemon, httpd, through this path:% ls -l /etc/httpd/total 12drwxr-xr-x 2 root root 4096 Apr 26 2011 confdrwxr-xr-x 3 root root 4096 Apr 26 2011 conf.d-rw-r--r-- 1 root root 18 Feb 24 2009 htpasswdlrwxrwxrwx 1 root root 19 Apr 26 2011 logs -> ../../var/log/httpdlrwxrwxrwx 1 root root 27 Apr 26 2011 modules -> ../../usr/lib/httpd/moduleslrwxrwxrwx 1 root root 13 Apr 26 2011 run -> ../../var/runThe modules link connects /etc/httpd -->/usr/lib/httpd/modules.

posted date: 2013-01-16 18:02:00


Re: How do I tell Apache which PHP to use?#7
The parent directory of modules loaded in httpd.conf (such as: libexec/apache2/libphp5.so) is defined by the ServerRoot 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:Relative paths in other configuration directives (such as Include or LoadModule, for example) are taken as relative to this directory.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.

posted date: 2013-01-16 20:34:00


Re: How do I tell Apache which PHP to use?#8
slm as i stated in the previous post, the ServerRoot is defined in the ServerRoot directive and has nothing whatsoever to do with HTTPD_ROOT which is displayed via "httpd -V." Please consult Apache's web pages referenced in my previous post, or if you'd like change the ServerRoot directive in your httpd.conf file and see for yourself.

posted date: 2013-01-18 00:45:00


Re: How do I tell Apache which PHP to use?#9
ServerRoot is a way to overrride HTTPD_ROOT. HTTPD_ROOT is set at compile time via the --prefix configure switch. Your post was distinguishing the different b/w ServerRoot and DocumentRoot. httpd.apache.org/docs/current/mod/core.html#serverroot. Good to see you registered a name with your SF account!

posted date: 2013-01-18 05:07:00


Re: How do I tell Apache which PHP to use?#10
See OSX Apache using wrong version of PHP

posted date: 2014-03-03 05:12:00


Re: How do I tell Apache which PHP to use?#11
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 apxsThis gave me the path to apache apxs APACHE_HOME/bin/apxsThis gave me info on which Apache is being used by this php. 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 0So in this way i was able to figure out the php used by Apache.

posted date: 2015-03-27 14:09:00


Re: How do I tell Apache which PHP to use?#12
Please don't post the same answer twice. Instead, link to the first answer.

posted date: 2015-03-27 14:40:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.