The list of tutorials, hints and howtos will grow slowly over time whenever I have the chance to write new ones.

1. How to replace missing libphp5.so
2. Compiling PHP with full GD functionality

"My libphp4.so/libphp5.so is missing!"

Download Apache from source: http://www.apache.org/dist/httpd/.

Next, untar it:

tar xvf httpd*.tar.gz

Then, cd into the directory: cd httpd*

Next, configure it. Replace PREFIXHERE with /wwwroot (this is optimal in case you want to upgrade Apache in the future), or some other directory like /etc. If you don't include --prefix, then Apache will be installed into /usr/local/apache2.

./configure --prefix=/PREFIXHERE --enable-so

The --enable-so line is important, if you don't include it, you will not have a libphp4.so file, and your server will not be able to parse PHP.

Next, type make

After this is done, make sure there are no old Apache processes running. If you purged any old Apache installations, this step should not be necessary, but nonetheless we want to make sure:

If you're on Ubuntu: /etc/apache2/bin/apachectl stop

Alternatively: /usr/local/apache2/bin/apachectl stop

Finally, type:
make install

Now we start the new server:
/path to apache/bin/apachectl start

Replace "path to apache" with whatever --prefix you used during ./configure.

Now, open up /path to apache/httpd.conf

Search for "modules/libphp4.so". If you find it, great. You can skip this step.

Otherwise, you'll have to search for "LoadModule", which should be under the section "Dynamic Shared Object (DSO) Support". Add a new line with the following:

LoadModule php4_module modules/libphp4.so

Now, search for "AddType". Add a new line under the line you found:
AddType application/x-httpd-php .php

Save the file, then restart the server:

/path to apache/bin/apachectl restart

Everything should be working now. :)

Compiling PHP with full GD functionality

Since I spent a few hours(!) trying to get full functionality of the GD library in PHP, I figured I should write a brief how-to for anyone who wants to use functions such as imagerotate(), imagettftext(), and imagefilter().

First, download the PHP tarball from here: http://php.net/downloads.php.

Next, untar it:

tar xvjf php*.tar.bz2


tar xvf php*.tar.gz

Then, cd into the new directory.

cd php*

If you already have PHP on your system, first remove it by typing (if you're on Ubuntu) apt-get purge php, or if you're on Gentoo, emerge unmerge php2.

Now, configure it. Just replace --prefix=/etc/php with whatever your prefix for Apache is, with /php added at the end. On Ubuntu, this would be --prefix=/etc/php but on other installations it might be /usr/local/share/php or possibly /wwwroot/php.

./configure --prefix=/etc/php --with-config-file-path=/etc/php --with-gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr

If you have MySQL installed, add --with-mysql to the configure line.

If PHP complains that you don't have libPNG or libJPEG installed, you may need to install these from source: http://sourceforge.net/projects/libpng/files/ and http://www.ijg.org/files/jpegsrc.v8b.tar.gz.

Now type type make and then make install. :) If all goes well, you should have full functionality of GD in PHP and should now be able to use imagefilter(), imagerotate(), etc.