Friday, July 29, 2011

Debian Lenny - Update PHP 5.2 to 5.3

It must be added the new source to apt-source. Edit the file /etc/apt/sources.list:

vim /etc/apt/sources.list

and add these lines to it:

deb stable all
deb-src stable all

 Download and import the dotdeb key:

cat dotdeb.gpg | sudo apt-key add -

Then remove all php packages from the system. For example in my case:

apt-get remove php5 libapache2-mod-php5 php5-gd php5-mysql
apt-get remove php5-curl php5-tidy php5-dev php-pear php5-cli
apt-get remove php5-common php5-suhosin

Update your sources:

apt-get update

and reinstall PHP packages:

apt-get install php5 libapache2-mod-php5 php5-gd php5-mysql
apt-get install php5-curl php5-tidy php5-dev php-pear php5-cli
apt-get install php5-common php5-suhosin

now the following command will show you the new PHP version:

php -v


because no longer has lenny packages, we install the PHP 5.3 manually:

mkdir /tmp/php5
cd /tmp/php5

download all PHP5 packages from (our example is PHP 5.3.10) :

wget -r -l 1

remove old version:

apt-get remove php5 libapache2-mod-php5  
apt-get remove php5-gd php5-mysql php5-curl 
apt-get remove php5-tidy php5-dev php-pear 
apt-get remove php5-common php5-mcrypt php5-cli

and install new PHP packages:

dpkg -i php5-common_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i libapache2-mod-php5_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5_5.3.10-1~dotdeb.0_all.deb
dpkg -i php5-mysql_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-curl_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-cli_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php-pear_5.3.10-1~dotdeb.0_all.deb
dpkg -i php5-curl_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-mcrypt_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-tidy_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-gd_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-dev_5.3.10-1~dotdeb.0_amd64.deb

restart the apache:

/etc/init.d/apache2 restart


james t said...

Unfortunately no longer has lenny packages...

Anonymous said...

nice post....for me it's very helpful and it works :)

Many Thanks

Nenad Bulatović said...

Is it possible to add
to sources list? To make it installable with apt.get?

Tehrani said...

If you mean for Lenny, I must say no, because has no longer support Lenny packages. But for squeeze is possible.

Nenad Bulatovic said...

I found a solution:

1. I made new directory
mkdir /root/downloads/php5.3
2. I downloaded all of the deb packages
wget -r -l 1
3. Created Packages.gz
sudo dpkg-scanpackages . /dev/null | gzip -c9 > Packages.gz
4. added this to sources.list
deb file:///root/downloads/php5.3 ./
sudo apt-get update
apt-get upgrade
apt-get dist-upgrade
And that's it

php -v
PHP 5.3.9-1~dotdeb.2 with Suhosin-Patch (cli) (built: Jan 13 2012 01:21:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Tehrani said...

@Nenad Bulatovic: cool, thanks for your comment

fahim-ansari said...

Hi, @Nenad Bulatovic,

thanks for your info, but after creating package and when i run apt-get update, i got file not found at /root/downloads/php5.3/./Sources.gz and also for Packages.gz. Where these .gz files stored and how to solve it?


Nenad Bulatovic said...

They should be in directory where you ran command for creation of packages.

However, you can do: "updatedb" and then "locate Packages.gz" to find where are they stored on your system.

Jackson said...

Hello I'm having problem when starting'll update this package, is giving error dependence.
dpkg-i php5-mcrypt_5.3.10-1 ~ dotdeb.0_amd64.deb
dpkg-i php5-tidy_5.3.10-1 ~ dotdeb.0_amd64.deb
dpkg-i php5-gd_5.3.10-1 ~ dotdeb.0_amd64.deb
dpkg-i php5-dev_5.3.10-1 ~ dotdeb.0_amd64.deb

Please how do I solve this problem?

(Reading database ... 30999 files and directories currently installed.)
Preparing to replace php5-mcrypt 5.3.10-1~dotdeb.0 (using php5-mcrypt_5.3.10- otdeb.0_amd64.deb) ...
Unpacking replacement php5-mcrypt ...
dpkg: dependency problems prevent configuration of php5-mcrypt:
php5-mcrypt depends on libmcrypt4; however:
Package libmcrypt4 is not installed.
dpkg: error processing php5-mcrypt (--install):
dependency problems - leaving unconfigured
Processing triggers for libapache2-mod-php5 ...
[ ok ] Reloading web server config: apache2.
Errors were encountered while processing:

Tehrani said...


Hi Jackson,

did you try to run this command after dependency problem:

apt-get -f install

riversy said...

Thanx for great post. Still actual.