php5 and php4 on same server as cgi

cd /usr/src

wget http://us.php.net/get/php-5.2.11.tar.gz/from/us.php.net/mirror

tar -zxf php-5.2.11.tar.gz
cd php-5.2.11
./configure –prefix=/usr/local/php5 –add_the_remaining_options_from_php4_expect_apxs
make
make install

check if binary is installed fine

/usr/local/php5/bin/php-cgi -v

 

Now run the following command

Code:
/usr/local/php5/bin/php-cgi  -v

It should show as cgi.

Now add the following lines on top of the httpd.conf file

Code:
ScriptAlias /php5/ /usr/local/php5/bin/
Action application/x-httpd-php5 /php5/php-cgi
<Directory "/usr/local/php5/bin/">
Allow from all
</Directory>

Save httpd.conf file and restart apache.

Open a .htaccess file inside the folder where you need php5 and add the following code to it. Make sure .htaccess support is enabled in your apache configuration.

Code:
AddHandler application/x-httpd-php5 .php

Make a phpinfo.php file in this directory and see what is shows when taken in browser. It should be php5.

See what it shows when the .htaccess line is commented. It should be php4 then.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: