Compiling and building PHP 5.3 on Ubuntu linux

Building PHP requires quite a bit of effort. There is a lot of dependencies before PHP 5.3.3 can be compiled plus every Linux distribution packages libraries in some different way. The result is that you have to install several Ubuntu packages before you can even compile PHP 5.3. Then you will need some more to make it run : )

This post shows how to make a development php, it is not supposed to be used for production as i am overriding default paths and you probably don't want to be doing that.

To make your and mine lives easier i put together a script how to get PHP 5.3 running on a fresh Ubuntu linux installation.

I installed fresh Ubuntu on Vmware to make sure i dont miss any of the packages that are necessary to compile PHP 5.3.

Steps before you begin compiling PHP 5.3

First you need compilers, configuration tools etc. To get them run this command

apt-get install make gcc autoconf bison re2c libxpm-dev libsasl2-dev libpspell-dev libreadline5-dev libsnmp-dev

Then you will need to install all of the dependencies of PHP 5.3 and its modules. Some of them have to be installed with C header files so that PHP can be build. In Ubuntu header files are packaged in separate -dev packages thats why you will need so many of them.

apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev apache2-utils apache2.2-common \
aspell libaspell-dev libxml2 libsnmp-base libsnmp15 libxml2-dev \
libbz2-dev libzip-dev libzip1 zlib1g zlib1g-dev \
curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls \
libc-client-dev libfreetype6 libfreetype6-dev \
libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev \
libmcrypt-dev libmcrypt4 libtidy-dev libxslt1-dev \
mysql-common mysql-server mysql-server-5.0 mysql-client mysql-client-5.0 mysql-server-core-5.0 

Downloading PHP 5.3.3

Now lets make sure we are not root any more as we do not want to accidentally mess up the system.

After you made sure you are a regular user go to your home folder, download php 5.3.3 sources and unzip them.

mkdir sources
cd sources

Go into the sources folder and run code below replacing ${dst} with the folder you want to install php inot (or set respective env variable)


./configure --prefix=${dst} \
--with-config-file-path=${dst} \
--with-config-file-scan-dir=${dst}/conf.d \
--without-t1lib \
--disable-short-tags \
--with-apxs2=/usr/bin/apxs2 \
--enable-pcntl \
--with-tsrm-pthreads \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd \
--with-pdo-mysql \
--with-openssl \
--with-zlib \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=${dst}/usr/lib \
--with-png-dir=${dst}/usr/lib \
--with-xpm-dir=${dst}/usr/lib \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-iconv-dir \
--with-gettext \
--with-imap \
--with-imap-ssl \
--with-ldap \
--with-ldap-sasl \
--enable-mbstring \
--with-mcrypt \
--with-mhash \
--with-pspell \
--with-readline \
--with-snmp \
--enable-soap \
--enable-sockets \
--with-sqlite \
--enable-sqlite-utf8 \
--enable-wddx \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-kerberos \
--with-tidy \
--with-curl \


make install INSTALL_ROOT=${dst}

With some luck it should work ;)

Even if it did not work for you the first time (you never know, maybe you have different version of Ubuntu or PHP) it should give you a fair idea of how to setup a custom installation folder and make PHP on ubuntu.

I will post a full bash script that automates the compilation and building process ..... coming soon.

Hope it helps


well it seems like you dont

well it seems like you dont have library installed.

As you said i would search in the configure script to see what locations is it searching for.

I would also google for the library package name in my system, id search package archives to look for kerberos and install missing library.

In debian/ubuntu should be quite easy i guess. Cant halp more than that i guess.

2011-12-14 00:18

Hi, I tried this, with few

Hi, I tried this, with few changes, but I keep getting this error (even when I remove changes I made)

configure: error: Kerberos libraries not found.
Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )

2011-12-08 03:12

i am not sure if it is that

i am not sure if it is that simple or maybe debian / ubuntu does some more mangling to locations of particular files.

You may lookup contents of the php package and see where do the files go.

2011-02-10 11:39

In ubuntu's packages for php,

In ubuntu's packages for php, whats the default "${dst}" ?

2011-02-07 02:22

Sorry but i am not sure what

Sorry but i am not sure what do you mean by 'make run exit' ?


2011-02-06 15:34

Hello, I compiled it and it


I compiled it and it works. Now which package do I have to install to make run exit? This is my list:

-rw-r--r-- 1 root src 2616182 2011-01-25 11:10 libapache2-mod-php5_5.2.4-2ubuntu5.14_amd64.deb
drwxr-sr-x 20 root src 4096 2011-01-25 11:10 php5-5.2.4
-rw-r--r-- 1 root src 1080 2011-01-25 11:10 php5_5.2.4-2ubuntu5.14_all.deb
-rw-r--r-- 1 root src 4256 2011-01-25 11:10 php5_5.2.4-2ubuntu5.14_amd64.changes
-rw-r--r-- 1 root src 171835 2011-01-25 10:48 php5_5.2.4-2ubuntu5.14.diff.gz
-rw-r--r-- 1 root src 1726 2011-01-25 10:48 php5_5.2.4-2ubuntu5.14.dsc
-rw-r--r-- 1 root src 9705468 2007-12-21 15:04 php5_5.2.4.orig.tar.gz
-rw-r--r-- 1 root src 5094718 2011-01-25 11:10 php5-cgi_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 2573096 2011-01-25 11:10 php5-cli_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 329002 2011-01-25 11:10 php5-common_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 25006 2011-01-25 11:10 php5-curl_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 400604 2011-01-25 11:10 php5-dev_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 108066 2011-01-25 11:10 php5-gd_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 17576 2011-01-25 11:10 php5-gmp_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 20228 2011-01-25 11:10 php5-ldap_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 5512 2011-01-25 11:10 php5-mhash_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 74342 2011-01-25 11:10 php5-mysql_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 37700 2011-01-25 11:10 php5-odbc_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 55866 2011-01-25 11:10 php5-pgsql_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 9508 2011-01-25 11:10 php5-pspell_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 5010 2011-01-25 11:10 php5-recode_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 12384 2011-01-25 11:10 php5-snmp_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 39472 2011-01-25 11:10 php5-sqlite_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 28622 2011-01-25 11:10 php5-sybase_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 17856 2011-01-25 11:10 php5-tidy_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 38582 2011-01-25 11:10 php5-xmlrpc_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 13520 2011-01-25 11:10 php5-xsl_5.2.4-2ubuntu5.14_amd64.deb
-rw-r--r-- 1 root src 360190 2011-01-25 11:10 php-pear_5.2.4-2ubuntu5.14_all.deb

Thank you for help!
Kind regards

2011-01-31 01:49

Post new comment


About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog. I am a passionate software engineer living in Sydney and working for Yahoo!

Web Scalability for Startup Engineers

If you are into technology, you can order my book Web Scalability for Startup Engineers on Amazon. I would love to hear what are your thoughts so please feel free to drop me a line or leave a comment.

Follow my RSS