Select PHP Google 云平台上的 wordpress 版本
Select PHP version for wordpress on Google cloud platform
我已经使用 Google 云平台 (GCP) 一段时间了,现在我在我的大多数 wordpress 网站上遇到错误,我需要更新我的 PHP
我用过
$ sudo apt install apt-transport-https lsb-release
$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg # Download the signing key
$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list.
$ sudo apt update
$ sudo apt-get install php7.3
To check the current version after the installation:
$ php -v
有效
现在
$ php -v
显示这个
PHP 7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb (cli) (built: Jul 10 2020 07:22:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb, Copyright (c) 1999-2018, by Zend Technologies
但是当我访问我的 wordpress 时它仍然显示我
Running PHP version: 7.0.33-29+0~20200514.36+debian9~1.gbp126f6f
我尝试了很多东西,但没有任何效果,例如
sudo update-alternatives --set php /usr/bin/php7.3
wp --info
现在显示为
OS: Linux 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1+deb9u1 (2020-06-07) x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.3
PHP version: 7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb
php.ini used: /etc/php/7.3/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/malriffaie
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
在 wordpress 上仍然存在同样的问题,我该怎么办?
您似乎安装了两个 PHP 版本:7.0 和 7.3。您可以检查:
$ php -v
PHP 7.3.20...
$ which php
/usr/bin/php
$ ls -l /usr/bin/php*
lrwxrwxrwx 1 21 May 13 09:02 /usr/bin/php -> /etc/alternatives/php
-rwxr-xr-x 1 4389936 May 14 09:11 /usr/bin/php7.0
-rwxr-xr-x 1 4708288 Jul 10 07:22 /usr/bin/php7.3
lrwxrwxrwx 1 25 May 13 09:02 /usr/bin/php-cgi -> /etc/alternatives/php-cgi
-rwxr-xr-x 1 4283768 May 14 09:11 /usr/bin/php-cgi7.0
如果目标是升级 PHP,而不是同时使用不同的版本,您应该删除以前的 PHP 版本,如下所述:
我已经使用 Google 云平台 (GCP) 一段时间了,现在我在我的大多数 wordpress 网站上遇到错误,我需要更新我的 PHP
我用过
$ sudo apt install apt-transport-https lsb-release
$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg # Download the signing key
$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list.
$ sudo apt update
$ sudo apt-get install php7.3
To check the current version after the installation:
$ php -v
有效
现在
$ php -v
显示这个
PHP 7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb (cli) (built: Jul 10 2020 07:22:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb, Copyright (c) 1999-2018, by Zend Technologies
但是当我访问我的 wordpress 时它仍然显示我
Running PHP version: 7.0.33-29+0~20200514.36+debian9~1.gbp126f6f
我尝试了很多东西,但没有任何效果,例如
sudo update-alternatives --set php /usr/bin/php7.3
wp --info
现在显示为
OS: Linux 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1+deb9u1 (2020-06-07) x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.3
PHP version: 7.3.20-1+0~20200710.65+debian9~1.gbpc9cbeb
php.ini used: /etc/php/7.3/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/malriffaie
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
在 wordpress 上仍然存在同样的问题,我该怎么办?
您似乎安装了两个 PHP 版本:7.0 和 7.3。您可以检查:
$ php -v
PHP 7.3.20...
$ which php
/usr/bin/php
$ ls -l /usr/bin/php*
lrwxrwxrwx 1 21 May 13 09:02 /usr/bin/php -> /etc/alternatives/php
-rwxr-xr-x 1 4389936 May 14 09:11 /usr/bin/php7.0
-rwxr-xr-x 1 4708288 Jul 10 07:22 /usr/bin/php7.3
lrwxrwxrwx 1 25 May 13 09:02 /usr/bin/php-cgi -> /etc/alternatives/php-cgi
-rwxr-xr-x 1 4283768 May 14 09:11 /usr/bin/php-cgi7.0
如果目标是升级 PHP,而不是同时使用不同的版本,您应该删除以前的 PHP 版本,如下所述: