The lowest cost option is to maintain such a system for as long as possible without introducing incompatible changes. Red Hat Enterprise Linux fits the bill with a support cycle of 7 years. RHEL 2.1 maintenance cycle runs until 31st May 2009. For web applications, the chief value of the maintenance cycle is the automated security updates. These keep the server patched against security flaws as they are detected.
From the above, it should be clear why updating the whole system, or major parts of the system is potentially dangerous and uneconomical. When the support cycle for your distribution is nearly over, it may be time to begin the costly and time consuming process of migrating the web applications to a new install. In the meantime, customers may demand enhanced functionality through off-the-shelf content management systems such as Joomla!, Mambo or Mediawiki, or use a modern content management system as a migration path from legacy code running on legacy systems. Opening the option of installing a recent version of PHP on a legacy system, and thereby opening a migration path is therefore of great value. Another point of value is extending the useful life of an installed system and associated hardware, and possibly avoiding the need to run concurrent systems until switch-over is required.
This document describes a process I have used to install PHP5 where for me, it only affects designated areas on the machine. Everything else has remained unaffected. [Please note: This information is given in good faith with the hope it will be useful. There is absolutely no express or implied warranty. Follow these instructions at your own risk!]
This document will concentrate on PHP suitable for running Joomla 1.0.12. Joomla will run with MySQL shipped with RHEL 2.1. If you want to run the latest mediawiki, you will need to run a recent version of MySQL as well as a recent version of PHP. A later document may include instructions on how to do this without affecting your running web applications. As always, make sure you have a working backup in case of disaster. When logged in as root, remember that it only takes a few wrongly chosen characters typed on the console to irretrievably wipe everything. Also remember that it is not the case of IF the hard drive will fail. It is the case of WHEN.
For example (as a user, not root)
cd /tmp wget ftp://xmlsoft.org/libxml2/libxml2-2.6.27.tar.gz tar -zxf libxml2-2.6.27.tar.gz
For example (as a user, not root)
cd /tmp wget http://uk3.php.net/get/php-5.2.1.tar.gz/from/uk.php.net/mirror tar -zxf php-5.2.1.tar.gz
cd /tmp cd libxml2-2.6.27 ./configure --without-python --prefix=/usr/local/libxml2 make su <enter root password> make install exitAssuming there were no errors, we should now have a compiled libxml2 installed in /usr/local/libxml2
cd /tmp/php-5.2.1 ./configure --without-python --prefix=/usr/local/php5 --with-zlib --with-mysql --with-libxml-dir=/usr/local/libxml2/ --with-gd --enable-exif make su <enter root password> make install exitWe should now have a compiled version of PHP for CGI only in /usr/local/php5
There are 2 programs given here. The bash option is easy, requires no compilation, but introduces an overhead which may be considerable with a lot of traffic. The C program option creates a tiny, fast wrapper which has almost no overhead.
Bash option:
#!/bin/bash /usr/local/php5/bin/php $@
Simple eh? Bash launches PHP and passes all parameters to PHP. Save the 2 lines into a file called phpwrapper
Alternatively, C programming option
//----Code starts here
#include <stdio.h>
#include <stdlib.h>
#define EXEC_STRING "/usr/local/php5/bin/php"
#define IMAGE_NAME "php"
int main(int argc, char **argv)
{
char **arguments;
int i,k;
arguments=malloc((argc+1)*sizeof(char*));
arguments[0]=IMAGE_NAME;
for(i=1;i<argc;i++)
arguments[i]=argv[i];
arguments[i]=0;
k=execv(EXEC_STRING,arguments);
printf("Wrapper program ret val %d, %s probably not found\n",k,EXEC_STRING);
}
//----Code ends here
gcc -O2 -o phpwrapper phpwrapper.c
This will create a binary called phpwrapper. About 14k in size. This program, or the bash script can be used interchangeably. The binary will be faster, and use less system resources.
As a security check, point the web browser to your wrapper script in your CGI-bin. eg http://www.host.name/cgi-bin/phpwrapper. If you see the line from the bash script or a line with ELF near the beginning, you are probably safe as Apache will serve, rather than execute the wrapper script for direct requests. (If you get internal server error, or PHP information, it is unsafe as attackers can execute arbitrary code on your PHP as your user).
Add the following lines to the virtualhost stanza. These tell apache to use the CGI version of PHP instead of any PHP apache module.
ScriptAlias /php5-cgi /home/httpd/vhosts/website.com/cgi-bin/phpwrapper Action php5-cgi /php5-cgi AddHandler php5-cgi .php
(Change the path to the actual copy of phpwrapper for the virtualhost).
You should now be able to run Joomla! 1.0.12 on RHEL 2.1 or Centos 2.1.
Note: To use search engine friendly URLs with Joomla/PHP run as CGI, you will need to add special apache directives, which are site-specific and beyond the scope of this document.
Sponsored link: Computer shop in Catford, SE6. Discount computers, parts. Linux, Windows, Mac