dumebi
dumebi

Reputation: 19

Downgrade from PHP 7 to PHP 5.6 on apache server

I just recently launched LAMP version 7.0 using bitnami on google app engine.

I couldn't find the older version of 5.6.

Any idea how i can downgrade the default PHP 7 to PHP 5.6 on my server

upon running this commandphp --version

i get this output

PHP 7.0.22 (cli) (built: Sep 6 2017 14:14:52) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22, Copyright (c) 1999-2017, by Zend Technologies

kindly note that i have also installed PHP 5 using sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

but the dafault PHP version remains PHP 7.0.22

Upvotes: 0

Views: 6167

Answers (2)

Juan Ariza
Juan Ariza

Reputation: 1058

Bitnami Stacks are self-contained. That means that they include every component they need (e.g. Apache, PHP, PHP-FPM, MySQL, etc.).

Those components are not installed using the System Package Manager of the Distro (e.g. yum on Centos or apt on Debian). Therefore, if you install a different version of PHP on your Image, you'll have two different PHPs installed. The one in the system and the one in the Stack. However, every component included in the Stack will use the PHP included in the Stack (no matter what version you installed in the system).

You can find the PHP in the LAMP Stack at /opt/bitnami/php. If you want to use PHP 5.X you have several options:

  • A. Download and install the LAMP Stack with PHP 5.6.x from https://bitnami.com/stack/lamp/installer on your server. After that, remove the previous LAMP Stack with PHP 7.
  • B. Install PHP using the System Package Manager. Then, modify the environment to remove /opt/bitnami/php from the PATH and also edit the file /opt/bitnami/scristps/setenv.sh to avoid including /opt/bitnami/php again in the PATH.

Upvotes: 1

Nilo_DS
Nilo_DS

Reputation: 939

It is possible just to install the version of php you need. and change the set-up.

ssh into your VM from your console or

gcloud compute ssh [INSTANCE NAME] --ZONE [INSTANCE ZONE]

Inside your VM do:

If add-apt-repository is not installed

sudo apt-get install software-properties-common python-software-properties

then:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php7.0-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
  • Apache:

    sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

  • CLI:

    sudo update-alternatives --set php /usr/bin/php5.6

Upvotes: 2

Related Questions