Building PHP 5.3 packages on Ubuntu 9.04 (Jaunty) for Apache 2

by Vid Luther on August 24, 2009

in blog, mysql, php, ubuntu, web

Goal: Build a PHP 5.3 package, that I can install and upgrade on new ubuntu slices as needed, without having to compile on each box.

This is an amalgamation of different blog posts that did certain things really well, but not everything I wanted. The post I refer to specifically Installing PHP 5.3 on Ubuntu by Brandon Savage .

Prep your system

Setup your development server to be able to compile things. By default, most installations will not come with compilers installed.

apt-get install checkinstall

Say yes, and let it follow the dependencies as needed.

Get the development headers for some of the extensions you’ll be compiling in.


apt-get install postgresql-8.3 postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-server-dev-8.3
aptitude install mysql-client mysql-client-5.0	mysql-common mysql-server mysql-server-5.0 mysql-server-core-5.0

apt-get install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62	libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm4-dev libmcrypt-dev libmcrypt4

Download PHP and Compile it


mkdir ~/srcs
cd ~/srcs

wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror
tar xvfz php-5-3-0.tar.gz
cd php-5.3.0

Now, you can either do the ./configure –help and pick your options, or you can use my configure options for PHP 5.3

make
make test

checkinstall

checkinstall will ask you some basic questions about the package, answer and let it build the package for you. You will run into an interesting issue at first, apxs2 will complain about a LoadModule not being in the httpd.conf file. This is an artifact of how Ubuntu/Debian likes to handle it’s configuration files. The simplest thing is to add a line at the bottom of your httpd.conf that loads a benign module. Mod Pony seems cute .

Configure your PHP like any normal apache server. Reload apache, put the handy phpinfo(); in your documentroot, and then have fun.
Be sure to remove the phpinfo(); from your production servers.

If you want MySQL 5.1, just do apt-get install mysql-server-5.1 , be sure to change the dev header packages to the same version as well.

  • Jay
    Thanks for your note, I built my php5.3 binary and everything works great. Except apache2 still loads the old version, do you know how I can point it to use the new php rather than the old version?

    Thanks!
  • strix
    why not just apt-get install "everything"?, wouldnt this be much better than "apt-getting" mysql and apache and then compiling php by itself....
  • Adrian
    Thanks so far. However, I have the problem that libphp5.so is not installed in /usr/lib/apache2/modules, only libphp5.a and libphp5.la

    This is part of the log:

    Installing PHP SAPI module: apache2handler
    /usr/share/apache2/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1.0/build/libtool' libphp5.la /usr/lib/apache2/modules
    /usr/share/apr-1.0/build/libtool --mode=install cp libphp5.la /usr/lib/apache2/modules/
    cp .libs/libphp5.lai /usr/lib/apache2/modules/libphp5.la
    cp .libs/libphp5.a /usr/lib/apache2/modules/libphp5.a
    ranlib /usr/lib/apache2/modules/libphp5.a
    chmod 644 /usr/lib/apache2/modules/libphp5.a
    libtool: install: warning: remember to run `libtool --finish /root/php-5.3.0/libs'
    Warning! dlname not found in /usr/lib/apache2/modules/libphp5.la.
    Assuming installing a .so rather than a libtool archive.
    chmod 644 /usr/lib/apache2/modules/libphp5.so
  • Vladimir
    Thanks mate. I was looking for two days anything helpful to upgrade my php, and this is only article i found usefull and easy to track.
    Awesome job, thank you very much!
  • Master
    make: *** No targets specified and no makefile found. Stop.

    I did word for word every step you outlined. I'm using Ubuntu 9.04, Apache 2, upgrading to PHP 5.3. HELP! >_<
  • Manuel Aude
    Problem solved, I had to compile with readline. Thanks anyway =)
  • Thanks for a great tutorial. For the step "Get the development headers for some of the extensions you’ll be compiling in.", I believe you also need the apache httpd header files, which means you also need to install the package 'apache2-prefork-dev'.
  • Manuel Aude
    Originally I had PHP 5.2.9 installed on Ubuntu using apt-get (typical installation).

    I did it in two ways: First, I didn't remove any packages and followed exact instruction from this tutorial. Everything pretty, except for the CLI.

    The second time, I removed everything related to PHP and compiled it all again. The CLI failed again.

    I'm on a x86 architecture.

    Thanks, btw =)
  • arif
    Hi Manuel,

    Did you mention php-5.2.9?

    mate i would be most grateful if you can tell me how i can install that step-by-step on a fresh ubuntu 8.10 or suse 11.1 install .

    i have develpped some scripts on windows wamp and i am inexperienced on linux, and i am using code using gd2 that only works on 5.2.9 . i need to convert my scripts to linux and try and setup a ghome server. plz include amy pre-requisite install.

    i am just getting errors and havent been able to get any where close.

    thank you.

    arif.
  • Manuel,
    did you upgrade from an existing install of PHP 5.2? What architecture are you working on? x86 or x86_64?
  • Manuel Aude
    Everything works except for Cli :S I'm justing Jaunty and the command line just hangs. php -v returns the right version, websites work, but CLI always fails (it just stays there, without even giving me the prompt). Any ideas on this?
  • There is a quicker way (if yo're living on the edge), you can simply try dotdeb packages http://www.dotdeb.org/2009/07/03/php-5-3-0-fina...
blog comments powered by Disqus

Previous post:

Next post: