PHP – How to Change Apache2 PHP Version

apache-2.2PHPphp.ini

Ubuntu 10.04, MySQL 5.1, Apache 2.2, and PHP 5.2/5.3:

I just discovered that I am using the wrong version of PHP for a CRM application. Once I figured out how to make a simple phpinfo() script to tell me what Apache2 is using, I tried changing the php.ini such that my webserver would use the PHP I want. Well, this is my problem. Not sure how to do that.

I compiled the version of PHP I want to /etc here:

/etc/php-5.2.8/

Inside this, there was a php.ini-recommended file that I made some changes to and renamed to php.ini so PHP would use it. But when I opened my browser and cleared my history and went to the http://localhost<CRM dir>/install.php address, the wizard still says I'm not usign the correct version of PHP.

Based on this post what do I have to do to change the version of PHP that shows up after I run my test.php script? In other words, phpinfo() says I'm running PHP 5.3.2, but I want to change it to my compiled 5.2.8 version located in /etc.

Best Answer

Depending on your server, you should be looking at Apache, not PHP.

(For RHEL/CentOS) look at /etc/httpd/conf.d/php.ini

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated web pages.
#
LoadModule php5_module modules/libphp5.so
#
# Causes the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

You'll see that your PHP module is modules/libphp5.so.

AddHandler php5-script .php tells Apache to run PHP on any file with the extension .php.

If you are using an RPM based OS it's probably easier to uninstall (assuming you can do that) the current version of PHP, and reinstall the version you are looking for.

rpm -qa | grep php

will show you what version of PHP is currently installed.

Related Topic