php5 and php4 on same server as CGI


php5 and php4 on same server as CGI
Sometimes we may have to run php4 and php5 on the same server. There is procedure to do this in cPanel server, otherwise you may end up in messing up whole server.

Steps:
====
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
===

Now, check if binary is installed:

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

It should show as cgi.

Now add the following lines on top of the httpd.conf file
===
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.

===
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.

About Linux Conquering Cloud

A guy who want to try out every thing ...
This entry was posted in PHP. Bookmark the permalink.

1 Response to php5 and php4 on same server as CGI

  1. Pingback: install alternate PHP version along with current version | Linux server administration tips

Leave a comment