简体   繁体   English

在 apache 服务器上从 PHP 7 降级到 PHP 5.6

[英]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.我最近刚刚在谷歌应用引擎上使用 bitnami 推出了 LAMP 7.0 版。

I couldn't find the older version of 5.6.我找不到 5.6 的旧版本。

Any idea how i can downgrade the default PHP 7 to PHP 5.6 on my server知道如何将服务器上的默认 PHP 7 降级到 PHP 5.6

upon running this command php --version运行此命令后php --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 PHP 7.0.22 (cli) (built: Sep 6 2017 14:14:52) ( NTS ) 版权所有 (c) 1997-2017 The PHP Group Zend Engine v3.0.0, 版权所有 (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22,版权所有 (c) 1999-2017,由 Zend Technologies

kindly note that i have also installed PHP 5 using sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt请注意,我还使用sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt安装了 PHP 5

but the dafault PHP version remains PHP 7.0.22但 dafault PHP 版本仍然是 PHP 7.0.22

It is possible just to install the version of php you need.可以只安装您需要的 php 版本。 and change the set-up.并更改设置。

ssh into your VM from your console or从您的控制台 ssh 进入您的 VM 或

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

Inside your VM do:在您的 VM 中执行以下操作:

If add-apt-repository is not installed如果没有安装 add-apt-repository

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 ;须藤 a2dismod php7.0 ; sudo a2enmod php5.6 ;须藤 a2enmod php5.6 ; sudo service apache2 restart须藤服务 apache2 重启

  • CLI:命令行界面:

    sudo update-alternatives --set php /usr/bin/php5.6须藤更新替代品 --set php /usr/bin/php5.6

Bitnami Stacks are self-contained. Bitnami Stacks 是独立的。 That means that they include every component they need (eg Apache, PHP, PHP-FPM, MySQL, etc.).这意味着它们包含了他们需要的每个组件(例如 Apache、PHP、PHP-FPM、MySQL 等)。

Those components are not installed using the System Package Manager of the Distro (eg yum on Centos or apt on Debian).这些组件不是使用发行版的系统包管理器安装的(例如 Centos 上的 yum 或 Debian 上的 apt)。 Therefore, if you install a different version of PHP on your Image, you'll have two different PHPs installed.因此,如果您在图像上安装不同版本的 PHP,您将安装两个不同的 PHP。 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).但是,Stack 中包含的每个组件都将使用 Stack 中包含的 PHP(无论您在系统中安装什么版本)。

You can find the PHP in the LAMP Stack at /opt/bitnami/php .您可以在位于/opt/bitnami/php的 LAMP 堆栈中找到/opt/bitnami/php If you want to use PHP 5.X you have several options:如果您想使用 PHP 5.X,您有多种选择:

  • A. Download and install the LAMP Stack with PHP 5.6.x from https://bitnami.com/stack/lamp/installer on your server. A. 从https://bitnami.com/stack/lamp/installer在您的服务器上下载并安装带有 PHP 5.6.x 的 LAMP 堆栈。 After that, remove the previous LAMP Stack with PHP 7.之后,使用 PHP 7 删除之前的 LAMP 堆栈。
  • B. Install PHP using the System Package Manager. B. 使用系统包管理器安装 PHP。 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.然后,修改环境以从 PATH 中删除/opt/bitnami/php并编辑文件/opt/bitnami/scristps/setenv.sh以避免在 PATH 中再次包含/opt/bitnami/php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM