Using Apache 2.2 and Php 5.4 for testing legacy applications on Ubuntu 14.04

In linux, php, server

For the past years, nginx become a standart for php projects. But if you have legacy apps that heavily depend on apache and htaccess rewrites, some times apache 2.4’s breaking changes is hard catch for a quick look. You can use Ubuntu 12.04 or Debian 7 without a problem with apache 2.2. But Ubuntu 14.04 LTS comes with apache 2.4 and thing go wild.

If you want to use apache 2.2 you have to downgrade your repo to 13.04(raring), do not use it on production, because raring support is come to an end.

You can use nano, gedit etc instead of vim editor.

Lets add raring repo first:

sudo vim /etc/apt/sources.list.d/ubuntu1304.list

Paste the lines below. I added universe repo, otherwise php5-fpm package may be broken interestingly. If you are using nginx on the same machine, this would be necessary.

#Ubuntu 13.04 repro for instead of 2.4
deb http://old-releases.ubuntu.com/ubuntu/ raring main universe

Let’s create another file for old versions of apache and php

sudo vim /etc/apt/preferences.d/apache22

Paste the lines below

Package: apache*
Pin: release a=raring
Pin-Priority: 500

Package: libapache*
Pin: release a=raring
Pin-Priority: 500

Package: php*
Pin: release a=raring
Pin-Priority: 500

Now you can update and install your packages.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install apache2 php5 libapache2-mod-php5

Bonus:
If you want to disable auto-start of apache, you can use this command.

sudo update-rc.d apache2 disable
Recommended Posts

Leave a Comment

Contact Me

I'm not around right now. But you can send me an email and we'll get back to you, asap.

Not readable? Change text. captcha txt