How to Install an Older Version of PHP Using Apt-Get

Install php 7.2 specific version 7.2.0 instead last version from apt

apt-get didnt work for me. The solution was install PHP 7.2.0 from sources.

# curl -O -L https://github.com/php/php-src/archive/php-7.2.0.tar.gz
# tar -zxvf php-7.2.0.tar.gz
# cd php-src-php-7.2.0/
# ./configure --prefix=/usr/local/php --enable-fpm --disable-short-tags --with-openssl --with-pcre-regex --with-pcre-jit --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif
--with-gd --enable-intl --enable-mbstring --with-mysqli --enable-pcntl --with-pdo-mysql --enable-soap --enable-sockets --with-xmlrpc --enable-zip --with-webp-dir --with-jpeg-dir --with-png-dir --with-xls --enable-fpm

# make

# make install

Can't install old version of php

TL;DR

So here's the issue in the How To you read: it does not outline every package in the specific version it is actually required. So it (probably) installed the correct PHP version, but not the correct cli version and for sure not the correct apache mod.

I managed to build an apt-get command that installs the correct apache and php version. So with that you have a basic installation (with not that many extensions and stuff) you can go ahead with:

apt-get install php5=5.3.10-2 php5-cli=5.3.10-2 php5-common=5.3.10-2 \
libapache2-mod-php5=5.3.10-2 apache2=2.2.22-1 apache2.2-common=2.2.22-1 \
apache2-mpm-prefork=2.2.22-1 ssl-cert apache2.2-bin=2.2.22-1

How i got there

I want to outline here how i got there for documenation purpose:

I basically startet with the php5 and php5-cli package and the run into a lot of apt-get issues that looks like that:

The following packages have unmet dependencies:
apache2-bin : Conflicts: apache2.2-common but 2.2.22-1 is to be installed
apache2.2-common : Depends: apache2.2-bin (= 2.2.22-1) but 2.4.7-1ubuntu4.13 is to be installed
libapache2-mod-php5 : Depends: apache2-mpm-prefork (> 2.0.52) but it is not going to be installed or
apache2-mpm-itk but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

The easiest way is then to run a madison to list the available versions and choose the right one (which in your case will probably always be the oldest one):

apt-cache madison apache2-mpm-prefork
apache2-mpm-prefork | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | http://us.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4 | http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
apache2-mpm-prefork | 2.2.22-1 | http://snapshot.debian.org/archive/debian/20120221T041601Z/ unstable/main amd64 Packages
apache2 | 2.4.7-1ubuntu4 | http://us.archive.ubuntu.com/ubuntu/ trusty/main Sources
apache2 | 2.4.7-1ubuntu4.13 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main Sources
apache2 | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | http://us.archive.ubuntu.com/ubuntu/ trusty-backports/main Sources
apache2 | 2.4.7-1ubuntu4.13 | http://security.ubuntu.com/ubuntu/ trusty-security/main Sources
apache2 | 2.2.22-1 | http://snapshot.debian.org/archive/debian/20120221T041601Z/ unstable/main Sources

And just to mention it, this is Apache 2.2 going to be installed. I have no idea how supported that still is, but I am sure that PHP 5.3 is way to old. You might expose yourself to quite a huge security issue.

How to install old versions of Xdebug

this worked for me. Thank you @LazyOne for help. :-)

sudo apt-get install -y php-pear php7.3-dev
sudo apt install -y php7.3-xdebug
sudo pecl install xdebug-2.9.3


Related Topics



Leave a reply



Submit