Simmons Consulting, the Website of Toby Simmons

HOWTO: Upgrade Ubuntu LTS 8.04 server to PHP 5.2.8


I recently had to upgrade an Ubuntu server to the latest version of PHP (at the time, 5.2.8) … the problem was the server was running Ubuntu 8.04 and the latest version of PHP available through the normal update channels is 5.2.4. The server is running 8.04 because that is the “long term support” version of Ubuntu.

Thanks to Tom Liu and, there is a binary build of PHP 5.2.8 for this version of Ubuntu. I know that real Linux studs would just compile their own, but I didn’t want to go through the build and fail, build and fail process and needed a quick fix. Here are the steps I followed to update my Hardy Heron to PHP 5.2.8.

The first thing I did was made sure my server was completely up to date, so I entered each of the following commands at a shell prompt.

  1. sudo apt-get update
  2. sudo apt-get safe-upgrade
  3. sudo apt-get dist-upgrade
  4. sudo apt-get install update-manager-core
  5. sudo do-release-upgrade

The second step was to edit my sources list so that I can update using a new repository (, specifically Tom’s repository with PHP 5.2.8). So, first I made a backup of my sources.list file:

  1. cd /etc/apt
  2. cp sources.list sources.list.backup

Then I edited the file (I used the editor “nano”) and added the following two lines at the bottom of the file (these are not commands to enter, but lines to paste in the editor):

  1. deb hardy main
  2. deb-src hardy main

Because the update program apt uses encryption keys to validate packages, I needed to import Tom’s repository keys in order to install stuff from his repository. I found the instructions on how to do this from this site. Here is the command I used:

  1. sudo apt-key adv --recv-keys --keyserver D8A1B072D21E28605A21D829FE91E998CB542C04

Finally, I did the upgrade using apt and restarted Apache:

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get dist-upgrade
  4. /etc/init.d/apache2 restart

A quick check revealed I was indeed upgraded! Here is a list of references I used to do this:

Comments (12) »

  1. Nic Bernstein says:

    Thanks for a really useful post!
    You have a couple of errors in your reference to apt-key. First off, the operator to that command should be “add” not “adv”. Secondly, your code fragment has en-dashes encoded into it, rather than hyphens, which breaks cut and paste:
    apt-key adv –recv-keys –keyserver D8A1B072D21E28605A21D829FE91E998CB542C04"
    should be
    apt-key add -recv-keys -keyserver D8A1B072D21E28605A21D829FE91E998CB542C04"

    Otherwise, thanks a lot for bringing this info together in one place!


  2. Nic Bernstein says:

    A correction to my last post. Those are not en-dashes, they are em-dashes. This the code fragment should be this:

    apt-key add --recv-keys --keyserver D8A1B072D21E28605A21D829FE91E998CB542C04

    not this:

    apt-key adv &s;#8211;recv-keys &s;#8211;keyserver D8A1B072D21E28605A21D829FE91E998CB542C04


  3. Nic Bernstein says:

    Okay, I give up trying to format that command to post properly. The point is that the recv-keys and keyserver commands both need to be prepended with a pair of dashes “–” not an em-dash “–”.

    Also, you were right, the operator to apt-key is “adv” not “add” even though the man page says nothing about “adv”.

    Thanks again, and forgive my numerous follow-ups.

  4. Toby Simmons says:


    Thanks for your notes. You are absolutely correct that the double dashes are munged (by WordPress) into em-dashes. I’ve done a bit a research and haven’t figured out how to fix that yet but it’s on the list, so to speak!



  5. Toby Simmons says:


    I found a way to fix the double-dashes: I use a plugin called highlight-source-pro and I’ve edited the code so that it will escape dashes into their html entity equivalent (-) … this prevents WordPress from replacing them with em-dashes.

    Thanks &


  6. damion says:

    Thanks! This helped me out of a bind re. PCI server security compliance and a ubuntu 8.04 install.



  7. how do i know what version this will install
    it has to be 5.2.8

  8. Toby Simmons says:

    I don’t know if you are spamming my site or not, but as the article title tells you, this will install 5.2.8.

    Do you realize you have commented half a dozen times on my site today?

  9. rossdavidh says:

    Hey, thanks! By the way, the apt-key command as you have it in the body of the text still says ‘-add’, which gives an error. It explains that it should be ‘-adv’ in the comments, but those why copy and paste (shame on me) without reading might find it confusing. :)

  10. mgseeley says:

    Anyone know of a repository for PHP 5.2.14 for Ubuntu LTS 8.04?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>