Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

debian

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)?

like image 421
Crimson1222 Avatar asked Sep 04 '15 20:09

Crimson1222


2 Answers

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.

like image 198
Julian Hille Avatar answered Nov 10 '22 00:11

Julian Hille


The distribution has had an update since then. As of today, the version has been bumped so try:

apt-get install php5=5.4.45

like image 33
tester Avatar answered Nov 10 '22 01:11

tester