我将php5更新为/并安装了PHP 7.
当我运行php -v
时:
PHP 7.0.23-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Aug 31 2017 12:52:39) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache **v7.0.23**-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
但我的phpinfo()还在:
PHP Version 5.5.31-2+deb.sury.org~trusty+1
我应该怎么做才能使用PHP7而不是PHP5?
答案 0 :(得分:5)
这是因为您的PHP CLI版本为7但Web使用的是5.5
从php5.x到php7.0:
网络:
sudo a2dismod php5.x ; sudo a2enmod php7.0 ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php7.0
从php7.0到php5.x:
网络:
sudo a2dismod php7.0 ; sudo a2enmod php5.x ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php5.x
代替x,你必须使用特定版本的ex 5.6
答案 1 :(得分:-1)
带有推荐的php-apache模块的最简单命令-
///从php5或php7.0更新/升级到php7.1
php -v
sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.1
sudo apt install php7.1-cli php7.1-xml php7.1-mysql
sudo update-alternatives --set php /usr/bin/php7.1
sudo apt-get install php7.1-gd
sudo apt-get install php-mbstring php7.1-mbstring php-gettext libapache2-mod-php7.1
sudo apt-get install php7.1-json
sudo apt-get install php7.1-soap
sudo service apache2 restart
sudo a2dismod php7.0
sudo a2enmod php7.1
sudo service apache2 restart
php -v