Sunday, 20 April 2008

Building A Legacy LAMP Stack

LAMPThere are many live sites on the web that were written in PHP3. In case you ever need to set up an environment for one, here's how:
  1. Download and compile MySQL 4. You can get the source in from the archives on the MySQL website.
  2. Download Apache 1.3, take a look here. As well as setting the prefix in the configure step, you'll need to enable mod_so with --enable-module=so.
  3. Download PHP3, you can find it here. Now here comes the tricky bit:
    • The MySQL 4 client libraries don't include DROP DATABASE and CREATE DATABASE bindings, so we need to remove these from the PHP source. Grep for mysql_drop_db and mysql_create_db and comment out the relevant lines and functions.
    • Set the MYSQL_LIB and MYSQL_INC environment variables before running configure. The PHP 3 configure doesn't pick up the default MySQL 4 paths (MYSQL_LIB=/usr/local/mysql/lib/mysql and MYSQL_INC=/usr/local/mysql/include/mysql).
    • Continue with a normal configure, make and make install, building a shared object for Apache (see the INSTALL file).
  4. One last thing. After following the INSTALL file instructions for editing the httpd.conf, you may need to add a FileHandler for php files as well as php3 files.
Note: This is not a long term strategy. PHP 3, MySQL 4 and Apache 1.3 are not actively maintained so they're bound to be riddled with problems (including security holes). Best to update as soon possible!

No comments: