Crimson1222 Crimson1222 - 7 months ago 731
PHP Question

How to install the latest version of PHP 5.4 on Debian 8 (Jessie)?

I'm trying to install PHP on Debian 8 for a project I'm working on. The project requires PHP 5.4 and can't any of the later versions of PHP (5.5 and 5.6). Whenever I install php5 using apt-get, it installs the latest available version of PHP 5.6. How do I install PHP 5.4.44 (or whatever the latest version of PHP 5.4 actuall is)?

Answer

You need to add the old stable (wheezy) repos to the apt sources lists . Create a file at:

/etc/apt/sources.list.d/wheezy.list

And add following content:

deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free

run following commands to update the repo infos and install php5.4.44

apt-get update
apt-get install php5=5.4.44-0+deb7u1

You should think about version pinning. You could do that similar to:

Create a file at:

/etc/apt/preferences.d/php5

Package: php5*
Pin: release a=oldstable
Pin-Priority: 700

Package: php-*
Pin: release a=oldstable
Pin-Priority: 700