Building PHP 5.3.0 on Ubuntu 8.04 Server
When I wanted to build the latest PHP for a server I found several guides online. Sadly none of them worked right away.
So after finally getting it all to work like I wanted to, I decided to quickly write up this guide.
I start with a clean Ubuntu 8.04 install. So, first things first:
sudo apt-get update sudo apt-get dist-upgrade sudo shutdown -r now
Now that we’re up-to-date, let’s begin:
sudo apt-get build-dep php5 sudo apt-get install libmcrypt-dev libc-client-dev checkinstall
Now we have all the crap to build PHP with. Let’s get PHP itself:
cd /tmp/ wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror tar xvzf php-5.3.0.tar.gz cd php-5.3.0/
Now all that is left is to build PHP…
./configure --prefix=/usr --with-apxs2=/usr/bin/apxs2 --with-config-file-path=/etc/php5/apache2 --with-config-file-scan-dir=/etc/php5/apache2/conf.d --mandir=/usr/share/man --disable-debug --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enable-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath --with-bz2 --enable-ctype --with-db4 --without-gdbm --with-iconv --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --enable-zip --with-exec-dir=/usr/lib/php5/libexec --without-mm --with-curl=shared,/usr --with-zlib-dir=/usr --with-gd=shared,/usr --enable-gd-native-ttf --with-gmp=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6 --with-png-dir=shared,/usr --with-freetype-dir=shared,/usr --with-t1lib=shared,/usr --with-ldap=shared,/usr --with-ldap-sasl=/usr --with-mhash=shared,/usr --with-mysql=shared,/usr --with-mysqli=/usr/bin/mysql_config --with-pspell=shared,/usr --with-unixODBC=shared,/usr --with-xsl=shared,/usr --with-snmp=shared,/usr --with-sqlite=shared,/usr --with-mssql=shared,/usr --with-tidy=shared,/usr --with-xmlrpc=shared --with-pgsql=shared,/usr --enable-gd-native-ttf --enable-dba=shared --with-openssl-dir=shared,/usr --enable-gd-jis-conv --enable-json --with-mcrypt=shared,/usr --enable-pcntl --with-pdo-mysql --with-pdo-odbc=unixODBC,/usr --with-pdo-pgsql=shared,/usr --with-pdo-sqlite --enable-xmlreader --with-tsrm-pthreads --with-imap --with-imap-ssl
I’m sure this doesn’t enable ALL features in PHP, but it works for me so far. If I’ll ever find I was missing something, I’ll be sure to update this post.
When building make sure to pass the correct number of CPUs to make with the -j parameter to safe some time.
make -j2
And now we wait…
Now we need to add these lines to our httpd.conf (which is empty in this case)
#LoadModule directive to aid module installations #LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so
Now we can build our .deb for PHP.
sudo checkinstall -D --install=no --fstrans=no --maintainer=your@email --reset-uids=yes --nodoc --pkgname=php5 --pkgversion=5.3 --pkgrelease=200908060830 --arch=amd64
And that’s it. Now you have a .deb which you can install on a different system or (as checkinstall told you) just put on this system with dpkg -i.
Have fun

November 9th, 2009 at 22:15
Hi, I’ve done almost exactly as described above, with the only difference that I installed Apache and MySQL first. I end up with a working installation but when I run phpinfo() it seems that neither gd, mysql or mcrypt are loaded. What may be the cause of this? I’ve very little clue as to what might cause this so I have trouble troubleshooting this myself, but if you don’t have a full answer, just a place to start would be appreciated.
November 28th, 2009 at 01:17
Did you have PHP installed prior to building it?
With the complexity of this build it’s hard to pinpoint what could cause it not to load certain portions of it. Especially given the massive amount of output during the build process it is hard to determine what went wrong without having seen it.
There are several other guides online explaining how to build PHP on Ubuntu. Maybe the process someone else describes will be more successful on your system.
Sorry for the late reply :\