Recently, I wanted to play around with some stuff which is available only in PHP 5.3.x (more about it later in a separate blog post) and so was looking for a way to install it on my Ubuntu server, where this blog is running.
After poking around a bit, I found that Karmic Ubuntu hasn’t upgraded to PHP 5.3.x yet and the only way to do is to compile from PHP source. Even though I am pretty comfortable doing it, I didn’t wanted to do it, because it is very difficult to upgrade at a later point in time.
I was continuing my research and then found that it is in fact possible to install PHP 5.3.x though apt-get or aptitude. I thought of documenting it here, so that it would be useful for others who want to do the same thing.
Adding dotdeb to the source list
First you should add dotdeb repository to your apt-get source list. Add the following two lines to your /etc/apt-get/sources.list file
sudo vim /etc./apt-get/sources.list
Adding dotdeb keys to keyring
Dotdeb packages are GPGsigned. Issue the following commands to add the keys to key-ring
Install PHP5 packages
Then issue the following command to retrieve the updated package list. I am using aptitude here; you can use apt-get as well.
sudo aptitude update
sudo aptitude upgrade
And then you can install PHP5 packages (and modules) using the normal install command.
sudo aptitude install php5 libapache2-mod-php5
Installing php5-dev package
The above method will install all php5-* packages, but php5-dev has some dependency issues with libtool packages. In order to solve that you have to manually install libtool v1.5.26. To do that use the following commands.
Now it’s time to enjoy the new features that are available in PHP5.3 🙂
Hi.
Do you have any idea why this tip may not work?
I have
root@server:/tmp# cat /etc/issue
Ubuntu 9.10 \n \l
and
root@server:/tmp# cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu karmic main restricted universe
deb http://archive.ubuntu.com/ubuntu karmic-updates main restricted universe
deb http://archive.ubuntu.com/ubuntu karmic-security main restricted universe
deb http://php53.dotdeb.org stable all
deb-src http://php53.dotdeb.org stable all
# for libicu38
deb http://security.ubuntu.com/ubuntu jaunty-security main
deb-src http://security.ubuntu.com/ubuntu jaunty-security main
# for libltdl3
deb http://archive.ubuntu.com/ubuntu hardy main
deb-src http://archive.ubuntu.com/ubuntu hardy main
deb http://archive.ubuntu.com/ubuntu hardy-updates main
deb-src http://archive.ubuntu.com/ubuntu hardy-updates main
But apt-get upgrade doesn’t update PHP5 to 5.3.
Is it possible any dependencies are still missing?
Make sure you add the keyring for dotdeb as well.
Also I had some issues with libtool. Try to see if it has any unmet dependencies.
This didn’t work for me either – Ubuntu seemed to think it already had the latest version…
Doesn’t work for me neither.
Cannot add the key.
doesn’t work for me either, went through all the steps, had trouble with the key but somehow i managed to get it with
wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg, and then did a successful sudo apt-get update, but when i try to upgrade , nothing happens, Ubuntu says I already have the up to date software
Ok got it. For you guys out there that may have run to the same problem as I have, just use
deb http://php53.dotdeb.org oldstable all
deb-src http://php53.dotdeb.org oldstable all
instead of the
deb http://php53.dotdeb.org stable all
deb-src http://php53.dotdeb.org stable all
and it should work, have fun with 5.3 🙂
These instructions have totally hosed my server. The cli and the web php are no longer installed. aptitude says they are broken and cannot fix them.
This doesn’t work. I follow the instructions to the letter (including the oldstable comment) and I still get PHP 5.4 which the scripts I am running can’t use.
i just spend 2 hours doing your tut. and it installed the same damn libs as it did before. im still @ php5.4. sigh
how do i undo your changes?