12
Nov/09
2

How to upgrade PHP in Ubuntu

I decided to upgrade my PHP version as part of my Moodle 2.0 install. It wasn’t easy. Here’s the answer:

Step 1 – Update and Upgrade your existing software repositories
sudo apt-get update
sudo apt-get upgrade

Step 2 – Add some extra repositories so you can get the latest version
sudo nano /etc/apt/sources.list

Then add the following to that file, and save it:

deb http://http.us.debian.org/debian stable all
deb http://security.debian.org/ stable/updates main contrib
deb http://packages.dotdeb.org/ stable all

Step 3: Update your new repositories
sudo apt-get update

(I got some 404 errors with this step, but you can ignore them)

Step 4: Install the latest version of php
sudo apt-get install php5-cli

Step 5: Restart Apache
sudo /etc/init.d/apache2 restart

Filed under: How To, Tech
Comments (2) Trackbacks (2)
  1. Thanks for this info. Unfortunately it broke something for me. Do you know how to reverse this procedure so I can go back to PHP 5.2.10 Ubuntu?

  2. Yeah, just:

    sudo nano /etc/apt/sources.list

    and delete the extra sources that you added, then save it, then update your sources:

    sudo apt-get update

    Then reinstall php, and restart Apache…

    sudo apt-get install php5-cli
    sudo /etc/init.d/apache2 restart

Leave a comment