无法在 ubuntu 18.04 中更改 php 版本
Unable to change php version in ubuntu 18.04
我正在尝试更改 ubuntu 18.04 中的 php 版本。
我想从 7.0 更改为 7.2。
我已将 php 更新为 7.2。
将 php 版本从 sudo a2enmod php7.2
.
更改为
在终端中:
$ php --ini
Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File: /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
在本地主机中:
<?php phpinfo();?>
PHP Version 7.0.30-1+ubuntu18.04.1+deb.sury.org+1
System Linux linux 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24
06:16:15 UTC 2018 x86_64
Build Date May 2 2018 12:44:20
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php/7.0/apache2
Loaded Configuration File (none)
Scan this dir for additional .ini files /etc/php/7.0/apache2/conf.d
在终端中:
php -version
PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 5 2018
05:00:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright
(c) 1999-2018, by Zend Technologies
我无法确定问题出在哪里。
在我清除 php 7.0 后也没有解决问题。
请尝试:
sudo apt install libapache2-mod-php7.2
sudo service apache2 restart
自从安装了 PHP 7.2 后,我的 Apache2 无法启动,但在我的 /etc/apache2/mods-enabled 文件夹中,我有 php7.0 文件。我不得不删除它们,然后 sudo apt install libapache2-mod-php7.2 --reinstall 使一切恢复正常。
你试试这个:
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo service apache2 restart
在这里你可以找到更多:
https://serverfault.com/questions/895746/switch-from-php-7-2-to-7-1-on-ubuntu-16-04-apache
这里:
https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/
你可以试试这个
sudo update-alternatives --set php /usr/bin/php7.2
之后
sudo a2dismod php7.0
sudo a2enmod php7.2
sudo systemctl restart apache2
alias setphp="sudo update-alternatives --config php;sudo update-alternatives --config phar; update-alternatives --config phar.phar; a2dismod php*.*;systemctl restart apache2"
把上面的别名放在
sudo nano ~/.bashrc
#在上面的命令之后就运行这条命令
a2enmod php<Your Desired Version> # like, a2enmod php7.4
现在您可以运行从您的终端命令“setphp”。
我正在尝试更改 ubuntu 18.04 中的 php 版本。
我想从 7.0 更改为 7.2。
我已将 php 更新为 7.2。
将 php 版本从 sudo a2enmod php7.2
.
在终端中:
$ php --ini
Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File: /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
在本地主机中:
<?php phpinfo();?>
PHP Version 7.0.30-1+ubuntu18.04.1+deb.sury.org+1
System Linux linux 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24
06:16:15 UTC 2018 x86_64
Build Date May 2 2018 12:44:20
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php/7.0/apache2
Loaded Configuration File (none)
Scan this dir for additional .ini files /etc/php/7.0/apache2/conf.d
在终端中:
php -version
PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 5 2018
05:00:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright
(c) 1999-2018, by Zend Technologies
我无法确定问题出在哪里。 在我清除 php 7.0 后也没有解决问题。
请尝试:
sudo apt install libapache2-mod-php7.2
sudo service apache2 restart
自从安装了 PHP 7.2 后,我的 Apache2 无法启动,但在我的 /etc/apache2/mods-enabled 文件夹中,我有 php7.0 文件。我不得不删除它们,然后 sudo apt install libapache2-mod-php7.2 --reinstall 使一切恢复正常。
你试试这个:
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo service apache2 restart
在这里你可以找到更多: https://serverfault.com/questions/895746/switch-from-php-7-2-to-7-1-on-ubuntu-16-04-apache
这里: https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/
你可以试试这个
sudo update-alternatives --set php /usr/bin/php7.2
之后
sudo a2dismod php7.0
sudo a2enmod php7.2
sudo systemctl restart apache2
alias setphp="sudo update-alternatives --config php;sudo update-alternatives --config phar; update-alternatives --config phar.phar; a2dismod php*.*;systemctl restart apache2"
把上面的别名放在
sudo nano ~/.bashrc
#在上面的命令之后就运行这条命令
a2enmod php<Your Desired Version> # like, a2enmod php7.4
现在您可以运行从您的终端命令“setphp”。