ubuntu16.04版本從默認源安裝的php版本爲7.x版本,咱們都知道php7.0已經捨棄了不少舊版本的函數等內容,這對舊系統來講是致命的,那麼,咱們就有了安裝舊版php的需求,而同一主機安裝兩個版本的php,若是不作配置會報錯。那麼,咱們就須要:php
1、卸載php7.x;mysql
1)若是咱們知道在安裝php7的時候都安裝了那些包及擴展,能夠直接使用命令(php_xxx爲您安裝的php集擴展)來卸載;sql
sudo apt-get - -purge remove php_xxx
2)不知道安裝了那些擴展,能夠使用如下方法來卸載;ubuntu
a、安裝aptiudephp7
sudo apt-get install aptitude
b、檢索並卸載php現有版本函數
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
2、安裝舊版php(我這裏以php5.6爲例).net
1)添加支持php5.6源blog
sudo add-apt-repository ppa:ondrej/php
2)更新ubuntu源ip
sudo apt-get update
3)安裝php5.6及經常使用組件rem
sudo apt-get install php5.6sudo apt-get install php5.6-gdsudo apt-get install php5.6-mysqlsudo apt-get install php5.6-mbstringsudo apt-get install php5.6-zip