Ubuntu 12.04, PHP 5.4, Apache2, and ppa:ondrej/php5

Okay, wow, what a doozy. I guess this is a lesson in why you want to be careful of the PPAs you use on your Ubuntu servers.

Summary

The very popular ppa:ondrej/php5, a Personal Package Archive for Ubuntu 12.04, upgraded from PHP 5.4 to PHP 5.5. This would require a newer version of Apache (v 2.4). If you upgraded Apache from 2.2 to 2.4, you would likely run into apache configuration issues.

If you want to continue to run PHP 5.4 instead of PHP 5.5, you can use the new PPA: ppa:ondrej/php5-oldstable

Problem

Of course it took me awhile to track down this issue because multiple things had changed on me, but yesterday my Vagrant project stopped working. When I would do a vagrant destroy and then a vagrant up I would get an error trying to install libapache2-mod-php5:


The following packages have unmet dependencies:
 libapache2-mod-php5 : Depends: apache2-api-20120211 but it is not installable
                       PreDepends: apache2 (>= 2.4)

So I checked out the PPA's page: https://launchpad.net/~ondrej/+archive/php5

I noticed it had a newer description. It took me awhile to realize it mentioned an older, more stable version. I scrolled down to see what version of php5 it had:


5.5.1+dfsg-1~precise+1

It had been updated on 2013-07-30, yesterday. So now my vagrant projects that used this PPA to install PHP 5.4 was installing PHP 5.5, it would cause libapache2-mod-php5 to break, which would cause all of my other packages and services to fail due to this dependency.

Solution

PHP 5.4

If you want to stay on PHP 5.4, you need to use the PPA ppa:ondrej/php5-oldstable.

PHP 5.5

You'll need to add the ppa:ondrej/apache2 as well to install Apache 2.4. Be warned, you might have stuff that chokes on Apache 2.4, so just be aware of that.

Final Thoughts

If you Google for "Ubuntu 12.04 PHP 5.4", you will get dozens of results saying to use ppa:ondrej/php5. However, now because you need a newer version of Apache, you'll likely get a lot of people with failed installs. This is going to be even worse if people do an aptitude upgrade and don't pay attention.

So if you know people who use Ubuntu 12.04 LTS and PHP 5.4, make sure they realize about the PPA update.

Justin is currently the Director of Development for the Deseret News. He is active in the Utah Open Source community. He is an advisory member of the Utah Open Source Foundation, and helps with the anual Utah Open Source Conference. He primarily focuses on PHP, MySQL, Redis, HTML, CSS, jQuery, and JavaScript. When he gets the time, he enjoys to play jazz piano. Read More

Tagged with: , , , , ,
Posted in Technology