Building the three of these is fairly easy, but a bit tricky if you’re used to how it worked in previous versions of Apache or PHP. Please note that we install everything into prefix trees and use a tool called graft to manage the versions. If you simply install your versions into default locations, you can probably leave out anything to do with prefix=, and top_dir. We also download all install archives into /usr/local/PKG_BUILD.

Anyway to get started, the first trick is to build Apache 2 first by itself. Here is an example:

This will install Apache into /usr/local/PACKAGES/httpd-2.2.8. If you want to make some modules shared (such as how we’re going to build mod_fastcgi shortly) then you can do so by adding things like: –enable-rewrite=shared.

This will actually find your httpd source and compile mod_fastcgi for you, as well as install it with the Apache 2 modules! (Easy huh?).

The final step is to download and install PHP 5. You can obtain PHP from http://www.php.net. After downloading:

cd /usr/local/PKG_BUILD
tar -xvzf php-5.2.4.tar.gz
cd php-5.2.4

Now the next part will no doubt differ depending upon what features you want to compile PHP with. That’s left up to you and google to work out how to compile the other modules. I’ll show what we compile some of our systems with, but the only ones that are really applicable to this blog are the –enable-force-cgi-redirect –enable-fastcgi ones.