Main menu

Post navigation

How To Upgrade To PHP 5.4 on Ubuntu

I am pretty sure I’ve mentioned that among my various other duties at work, I manage the network security program as well. One of the things we have to do on a regular basis, which I think all companies should do, is perform frequent penetration tests on our public web servers. It is good to find your holes, and plug them up before the bad guys do. I mean, you hear about it all the time where companies report security breaches where millions of their users credit cards are stolen. If they were performing regular scans, they may have been able to prevent that.

Well our latest scan came up pretty bloody on one of our WordPress servers. We got dinged pretty hard for running PHP 5.3.2, which is the version that comes from the repositories on Ubuntu 11.04. Even a simple apt-get upgrade won’t help with that. I looked at perhaps upgrading the server to 12.04, but the repository for that only has 5.3.10 which has it’s own problems. Nope, I needed to go even higher.

It turns out, there is a third party repository that has the latest versions of PHP so you don’t have to compile it yourself. To install just do the following from a terminal:

For Ubuntu 11.10/12.04:

sudo add-apt-repository ppa:ondrej/php5

sudo apt-get update

sudo apt-get install php5

For Ubuntu 10.04 LTS, run the following commands (Thanks to Ivan Castellanos for the extra tip):

You can check if PHP 5.4.x is successfully installed with this command:

php5 -v

I also use phpmyadmin, and as I mentioned above I also use WordPress which requires php5-mysqladmin. Well upgrading to php 5.4.4 forced me to remove phpmyadmin and php5-mysql because they required libmysqlclient16 which it said was uninstallable. What I had to do was run the following to install it: