Install old PHP version on Ubuntu

2020-02-16 04:26发布

问题:

I have got an Ubuntu14.04 and a PHP 5.5.9 installed.
Now I need PHP 5.4.*

As I have seen, it is not possible to downgrade it.
I have to purge it and then install the old version.

I have searched everywhere but I can't find an instruction how to get an old PHP version which works.

I already tried to get it with apt-get install php5=version, but apt-cache policy php5 does always only show PHP 5.5.9
And also
wget php5.4....
./configure
make
make install
doesn't work.

What is the solution for my problem?

回答1:

Download Apache http and PHP from source and it can be done.

Choose an installation source location; personally I use /usr/local/src but I've seen many alternatives.

Download Apache HTTP of the appropriate version (probably 2.4, I use the tar.gz files) http://httpd.apache.org/download.cgi

Download your PHP http://php.net/get/php-5.4.42.tar.gz/from/a/mirror

You will need to unzip (tar -zxvf), configure, make, make install both httpd and php. There are tons of configuration options you'll need to consider with both. You may hit many obstacles along the way and need to install various packages with apt-get but don't despair - search for the errors and you will find help, for example

Before you begin installing, make sure you've completely removed all remnants of php5.5

Good luck and post your results.



回答2:

Add this line to .htaccess to downgrade php version to 5.4

AddHandler x-mapp-php6 .php

for more details check this link https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/php-c37728/manually-set-the-version-of-php-using-an-htaccess-file-a614325.html