I'm developing one web application, using PHP eclipse IDE. For an instance i want to switch from one PHP version to another version which resides in different location.

Below is my working environment :

1) Having Centos OS

2) PHP 5.1.6 have installed already while installing centos OS

3) Above PHP is installed in /usr/bin/ path

4) I have installed LAMPP in /opt/lampp

5) In LAMPP present PHP 5.2.6 version

I want to configure local web server such that lampp should choose PHP 5.1.6 (which resides in /opt/lampp ) I am not aware of this switching of PHP version.

Please suggest me how should i configure this switching of PHP version in my local web server. Which configuration file should i choose for modifying this change.

Thanks a lot !!!



Apache is configured to load the PHP module. On CentOS this is configured in /etc/httpd/conf.d/php.conf. Look for the following line:

LoadModule php5_module modules/libphp5.so

That points to a relative path. Use the following command to find all your instances of libphp5.so:

find / -name libphp5.so

You should then be able to locate both versions of the PHP module. The one in /usr/lib/httpd/modules will be the one Apache is currently using. The one under /opt/lampp will (probably) be the one you want to use.

You can then either change the LoadModule directive above to point to the absolute path of the appropriate PHP module, or you could just copy it over the one in /usr/lib/httpd/modules. Either way, remember to restart Apache after making the change, or stop Apache, then make the change, and start Apache again.

A third option is to use yum to update PHP on the server to the newer version - that should overwrite the version of PHP in the standard location, and will provide a more straightforward update path in future.


Simplest solution would be to add a CGI handler for 5.1.6 then use different file extensions to select between the mod_php (5.2) and the CGI version. Something like:

Action phpa-exe /usr/bin/php
AddHandler phpa phpa-exe 

But bear in mind that the CGI version will run a lot slower than the module.

Also - both engines may try to load the same php.ini file - and potentially the same set of extensions (which will probably fail). So you might want to use something like:

Action phpa-exe "/usr/bin/php -c /etc/5.1.6/php.ini"


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.