Downgrade PHP 7 to PHP 5.6 on Ubuntu 16.04

Downgrade PHP 7 to PHP 5.6 on Ubuntu

ubuntu16.04 系统源自带是7.0的,如何降级安装PHP 5.6呢 .?

apt-get install -y language-pack-en-base
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
add-apt-repository ppa:ondrej/php
apt-get update
apt-cache search php5
apt-get install php5.6-common
apt-get install libapache2-mod-php5.6

如果需要解析xml	apt-get install php5.6-xml

Warming:

apt-get install libapache2-mod-php5.6

	libapache2-mod-php5.6: php7.0 module already enabled, not enabling PHP 5.6

apt-get install libapache2-mod-php5.6

	php7.0 module already enabled, not enabling PHP 5.6update-alternatives --set php /usr/bin/php5.6

解决方法:

(shell执行切换为php5.6)
update-alternatives --set php /usr/bin/php5.6

php -v
PHP 5.6.29-1+deb.sury.org~xenial+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

注释掉php7.0的相关库

/etc/apache2/mods-available/php7.0.load

# Conflicts: php5
#LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so

版本切换:

From php5.6 to php7.0 :

Apache:

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

CLI:

update-alternatives --set php /usr/bin/php7.0

From php7.0 to php5.6 :

Apache:

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

CLI:

sudo update-alternatives --set php /usr/bin/php5.6
posted @ 2017-01-07 01:36  JeromePowell  阅读(430)  评论(0编辑  收藏  举报