Jul 12, 2012

How To Upgrade To PHP 5.4 on Ubuntu

Official Ubuntu circle with wordmark. Replace ...
 (Photo credit: Wikipedia)
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):
  • sudo echo "deb http://ppa.launchpad.net/ondrej/php5/ubuntu lucid main" >> /etc/apt/sources.list
  • sudo echo "deb-src http://ppa.launchpad.net/ondrej/php5/ubuntu lucid main" >> /etc/apt/sources.list
  • sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E5267A6C
  • sudo apt-get update
  • sudo apt-get install php5
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:
  • wget http://security.ubuntu.com/ubuntu/pool/main/m/mysql-dfsg-5.1/libmysqlclient16_5.1.63-0ubuntu0.10.04.1_amd64.deb
  • sudo dpkg -i  libmysqlclient16_5.1.63-0ubuntu0.10.04.1_amd64.deb
  • sudo apt-get install php5-mysql phpmyadmin
After that, everything was back to normal.
Now that you are up to date, you should be good for future security scans as well... That is, until the next vulnerability is discovered :-)
[Via Up Ubuntu]



Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | spam filter in the cloud