View Single Post
Old Mar 6th, 2007, 18:08   #1
SolidHost Crew
Join Date: Nov 2006
Posts: 3
Default Install PHP4 with PHP5 (DirectAdmin or Plain server)


Following are the steps to run PHP4 with PHP5:

First you need to compile php4 with apache and need to install php5 but do not compile it with apache.
You can use normal configure command to compile php4 with apache.

Now PHP5 Installation.

You can download the version of PHP5 you would like to install from

REMOVE the "--with-apxs=/usr/local/apache/bin/apxs" from the line. We are going to compile CGI version and it may broke the Apache!

b) Make sure you have the following prefixes and suffixes to install to the proper directories - otherwise currently installed php could be broken:
--prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --program-suffix=5

c) Add the necessary options for proper CGI redirects from Apache:
--enable-force-cgi-redirect --enable-discard-path

The result line will looks like this (please, do not use it - it has no CURL and PostgreSQL support - you better to follow steps below):

#./configure --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --program-suffix=5 --with-xml --enable-bcmath --enable-calendar --enable-ftp --with-gd --enable-exif --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mbstring=all --enable-mbstr-enc-trans --with-mcrypt --with-mhash --enable-magic-quotes --with-mysql=/usr --with-openssl --enable-discard-path --with-pear --enable-sockets --enable-track-vars --with-ttf --with-freetype-dir=/usr --enable-versioning --with-zlib --with-pspell --with-gettext --enable-inline-optimization --disable-debug --enable-force-cgi-redirect --enable-discard-path

#make install

#ln -s /usr/local/lib/php.ini /usr/local/php5/lib/php.ini

It is recommended to add the following line to the php.ini at the bottom (it is a MUST if you compile php4 instead php5!). Note that this line will broke regular php4. As a common rule - if you are using the same php.ini, do not add this line:

cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode

Now we need to add several lines to Apache

#vi /usr/local/apache/conf/httpd.conf

Scroll down (better use the built-in search) to the "<IfModule mod_dir.c>"
There we should to add index.php5 after, but before index.php4. Result would looks like this:
<IfModule mod_dir.c>
DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.php5 iindex.php4 index.php3 index.php index.phtml ndex.htm default.htm default.html home.htm

This to allow index.php5 as index file.

Continue editing. Find the "AddType application/x-httpd-php .phtml" and after it add this:
# PHP 5 Implementatie
ScriptAlias /php5/ /usr/local/php5/bin/
<Directory /usr/local/php5/bin/>
Options +ExecCGI
AllowOverride All

AddType application/x-httpd-php-5 .php5
Action application/x-httpd-php-5 /php5/php

#service httpd configtest
#service httpd stop
#service httpd start

Best Regards,
Samuel Taylor
SolidHost Engineer
SH-Samuel is offline   Reply With Quote