I recently installed PHP 5.3 in order to play with some of the new features and thought I’d share the steps I took with you. While it’s based on a clean installation of Ubuntu 7.10 Server, you might find this useful on existing systems too.
You might also like to look at my SitePoint article on What’s new in PHP 5.3 to get an idea of the benefits and new features.
As ever, this guide is for educational purposes only. I offer no warranty of suitability or accuracy. Use at your own risk, and if it goes wrong head over to the forums for help…
Installing Required Applications
Before compiling PHP from source, you’ll need to make sure certain required tools and libraries are available:
aptitude install apache2 apache2-dev apache2-mpm-prefork apache2-utils aspell curl libaspell-dev libbz2-dev libc-client-dev libcurl3-dev libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libmcrypt4 libmcrypt-dev libmhash2 libmhash-dev libming-dev libmysqlclient15-dev libncurses-dev libpng3 libpng3-dev libpspell-dev libreadline-dev libsasl2-dev libsnmp-dev libt1-5 libt1-dev libtidy-dev libxml2 libxml2-dev libxml2-utils libxpm4 libxpm-dev libxslt-dev make mysql-client-5.0 mysql-server-5.0 |
Download PHP
PHP 5.3 is (at time of writing) only available as source or Windows binary. If you’re reading this, you’re probably not installing it on a Windows machine…
Head over to the PHP Snapshots site and make a note of the latest PHP 5.3 snapshot version. At the time of writing, this was php5.3-200801100530. I generally download the bziped versions as they are slightly smaller.
cd ~ mkdir download cd download/ wget http://snaps.php.net/php5.3-200801092330.tar.bz2 tar xjf php5.3-200801092330.tar.bz2 cd php5.3-200801092330 chown -R root.root . |
Configure PHP
I generally enable a lot of options. This configure command will enable most of the things you’ll need. Enabling other extensions might require you to install extra libraries.
./configure --with-apxs2=/usr/bin/apxs2 --disable-short-tags --with-openssl --with-zlib --enable-bcmath --with-bz2=/bin/bzip2 --enable-calendar --with-curl --with-curlwrappers --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-xpm-dir=/usr/lib --with-ttf --with-t1lib --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-imap --with-imap-ssl --with-ldap --with-ldap-sasl --enable-mbstring --with-mcrypt --with-mhash --with-ming --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-ncurses --with-pdo-mysql --with-pspell --with-readline --with-snmp --enable-soap --enable-sockets --without-sqlite --enable-sqlite-utf8 --with-tidy --enable-wddx --with-xmlrpc --with-xsl --enable-zip --with-pear --with-kerberos |
Installing PHP
Now the PHP make install script assumes that your LoadModules commands are in /etc/apache2/httpd.conf. Ubuntu, as Debian, doesn’t use this file. It exists, but it’s empty. If you try to install PHP with an empty httpd.conf, the installation will abort after failing to find any existing LoadModule statements in that file.
To circumvent this issue, I added a LoadModule line to the httpd.conf file:
echo "# Dummy comment" > /etc/apache2/httpd.conf echo "LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so" >> /etc/apache2/httpd.conf |
I then run the make and make install process:
make && make install |
Assuming the installation was a success, I then grap the new LoadModule line and put it into the mods-available directory to match the Ubuntu/Debian style of apache2 configuration:
cat /etc/apache2/httpd.conf | grep libphp5 > /etc/apache2/mods-available/php5.load |
Then I truncate the httpd.conf file again to avoid confusing apache when we restart it:
rm -f /etc/apache2/httpd.conf && touch /etc/apache2/httpd.conf |
Finally, we enable the module and restart apache:
a2enmod php5 apache2ctl configtest && apache2ctl restart |
Testing
If you pop up a browser and enter the IP address of your server into the address bar, you should get something like this:
Create a quick index.php file and reload the page:
echo "<?php phpinfo();" > index.php |
And you now have a working PHP 5.3 server.
Next Steps
Please note that the testing above is the full extent of the testing I’ve performed so far. I have no idea if any of the extensions work. I haven’t tried connecting to MySQL or doing any GD work. I’ve no idea if it will successfully connect to a remote IMAP server over SSL. If you get this far and it works as it did for me, and yet something in your PHP scripts doesn’t work, head over to the mailing list and let’s chat!
Good luck!

You have to make sure that APXS is installed, otherwise the –with-apxs2=/usr/bin/apxs2 option will throw an error. On Ubuntu this requires installing the apache-threaded-dev package.