Had a little project for setting up a host for development / hosting legacy stuff and found that the information about this is pretty scattered / shitty. So, here goes. Done on a recent Ubuntu but should be pretty straight-forward on any distro:
1. Install apache2, libxml2 and libapache2-mod-fcgid (apt-get install, yum install, pick your poison..)
2. Configure && compile your PHP. For the 5.2 branch you need to throw in a patch (wget that to your php-5.2.17-dir and say patch -p0 < filename.patch) to compile against more modern libxml2. The options for enabling fastcgi support have changed with pretty much every release, but this does the trick: ./configure –enable-fastcgi –with-fastcgi –enable-cgi && make
3. Create wrappers for all your php versions. We’re being lazy here and run them directly from /usr/src/ where we compiled it. No messy make installs. Pretty much like this:
# Set desired PHP_FCGI_* environment variables.
# PHP FastCGI processes exit after 500 requests by default.
# Replace with the path to your FastCGI-enabled PHP executable
4. Set up your virtual hosts:
AddHandler fcgid-script .php
DirectoryIndex index.php index.html
5. Restart apache. Open a beer. Hooray!