Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fed

Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fed


Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fed

We have  spent a few hours compiling information from around the net to get PHP4 & PHP5 working simultaneously. we thought we  write up what we had to do and hope this can help others.

Note: This is not a set up you might use for a sharing hosting scenario, this is just for our solo server where Apache runs under a ‘www’ user, and we dont don’t have SSH. For a more secure set up you’d probably want to use suphp / SuExec etc.

we  assuming you’ve already got PHP4 happily running as an Apache module. These instructions only cover installing FastCGI, PHP5 & configuration.


cd /usr/src/ wget wget tar xzf fcgi-2.4.0.tar.gz tar xzf mod_fastcgi-2.4.2.tar.gz cd fcgi-2.4.0 ./configure && make && make install cd ../cd mod_fastcgi-2.4.2

$ apxs -o -c *.c $ apxs -i -a -n fastcgi

cp Makefile.AP2 Makefile make && make install

If you were successful you’ll see ‘’ in your Apache modules dir. In our  case:


ls -l /usr/local/apache2/modules/ -rw-r–r– 1 root root 8440 Feb 28 2005 httpd.exp -rwxr-xr-x 1 root root 345172 Apr 29 16:54 -rwxr-xr-x 1 root root 140451 Feb 6 2005

Check that this line exists in your httpd.conf (typically it should be found near the top with other LoadModule statements):

LoadModule fastcgi_module modules/

Now we need to configure FastCGI.

mkdir -p /tmp/fcgi_ipc/dynamic chmod -R 777 /tmp/fcgi_ipc/

Next edit your httpd.conf and add the following.

This line is optional but if you choose not to include it, apache will check the document root of the current site – this gives you per site configuration of Fast CGI; for me it was overkill and I only needed one file to define these settings so I aliased it and put the config file in apache’s cgi-bin dir.

ScriptAlias /php5.fcgi “/usr/local/apache2/cgi-bin/php5.fcgi”

# FastCGI directives AddHandler fastcgi-script .fcgi FastCgiIpcDir /tmp/fcgi_ipc/ FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -pass-header HTTP_AUTHORIZATION

Add these lines below your PHP4 ‘AddType’ directives to bind the .php5 file extension to your FastCGI config script ‘php5.fcgi’:


AddHandler application/x-httpd-php5 .php5 Action application/x-httpd-php5 /php5.fcgi

Next create your ‘php5.fcgi’ and add the following:

#!/bin/sh PHP_FCGI_CHILDREN=2 export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_MAX_REQUESTS exec /usr/local/php5/bin/php

Make sure ‘php5.fcgi’ has the correct permissions & user/group so Apache can access it. Apache runs under ‘www’ on our box, please specify the appropriate user & group.

chown www:www php5.fcgi chmod 755 php5.fcgi

Now it’s time to install PHP5. It’s probably worth matching your PHP4 configure line which can be found on the phpinfo() page. To find out the available configure options type ‘./configure –help’. Whats important are the configure switches we have shown and that you specify a prefix path to install PHP5.

cd /usr/src wget tar xjf php-5.1.2.tar.bz2 cd php-5.1.2 ./configure –with-config-file-path=/usr/local/php5/php.ini –prefix=/usr/local/php5 –enable-fastcgi –enable-discard-path –enable-force-cgi-redirect …your switches… make && make install cp php.ini-dist /usr/local/php5/php.ini

You can check the installation was successful:

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

the code should be

Now restart apache. Then create a phpinfo() page with the extension .php5 (eg. phpinfo.php5 – don’t forget to remove this once you’ve confirmed PHP5 is running successfully!)

If this hasn’t worked check the modules Apache has loaded, specifically mod_action.

/usr/local/apache2/bin/apachectl -l

Hopefully you’ve now got PHP5 running along side PHP4!

About The Author: Brent

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.