Issue
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)?
Solution
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
Edit: The version of PHP5.4 has been updated to 5.4.45 so you may do a version lookup before installing this specific version and just replace the version number with the newest.
Answered By - Julian Hille Answer Checked By - Senaida (WPSolving Volunteer)