Deru Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

Running php4 and php5 together in server

Views: 1116
Votes: 0
Posted: 26 Dec, 2007
by: Prasad P.
Updated: 26 Dec, 2007
by: Prasad P.
Normally, there will be one version of php in server that is running as Apache API. We can configure another version of php for a domain, and we run this php as CGI.

In this article, I assume that php4 is running server wide and configured as Apache API. We will configure php5 as CGI for a domain say domain.com with DocumentRoot /home/user/public_html.

The server wide php4 will be installed either in /usr or /usr/local folder. We will install the new php5 into a different folder say, /usr/local/php5

Following are the steps

1. Download, compile and install the source.

cd /usr/local/src
tar -xjf php-5.2.3.tar.bz2
cd php-5.2.3
./configure --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --with-mysql
make
make install


In the above example, I compiled php5 with only mysql support. You need to specify other options if you need support for them.

It will install the php5 into the folder /usr/local/php5. You will be able to see the following folders, if the compilation is successfull.

bin/  etc/  include/  lib/  man/

and inside the bin/ folder you will have the required binaries.

2. Configure Apache to use php5 for domain.com domain.

Add the following Directory tab outside the VirtualHost entry for domain.com.

<Directory /home/user/public_html>
        AddHandler php-script .php
        Action php-script /cgi-bin/php-cgi
</Directory>


Now, if any php file in that domain is referenced, it will use the php-script handler to process the php file. The action script specified in the above example is under the cgi-bin folder. So we need to copy the php cgi binary into that folder.

cp /usr/local/php5/bin/php-cgi /home/user/public_html/cgi-bin/

We are done!

The configuration of new php can be verified by putting a phpinfo page in that domain.

Tips: If apache is looking for the php binary in folder /usr/local/apache/ folder, you need to copy that php-cgi binary into the cgi-sys folder.
Others in this Category
document CGI: debugging Internal Server Error
document Configuring mod_jk for apache in Cpanel server ?
document How do you use different characterset using .htaccess?
document Useful Exim Commands.
document How you replace your php fopen function with curl?
document How to use curl to get the file contents
document How to install SSH2 for PHP Shell?
document Album access issue in Gallery
document How to install APC (Alternative PHP Cache)
document Steps to enable SMTP Authentication - in different email clients



RSS