升级php至7.4版本

由于php版本是7.2,被标记为不安全版本[1],需要升级至7.4版本

ubuntu@xxx:~$ php -v
PHP 7.2.33-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug  7 2020 14:43:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.33-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
ubuntu@xxx:~$ ll /etc/apache2/mods-enabled/               
total 8
drwxr-xr-x 2 root root 4096 Feb  7  2019 ./
drwxr-xr-x 8 root root 4096 Jul 25 14:02 ../
lrwxrwxrwx 1 root root   36 Jan  9  2017 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root   28 Jan  9  2017 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 Jan  9  2017 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 Jan  9  2017 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 Jan  9  2017 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   30 Jan  9  2017 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 Jan  9  2017 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 Jan  9  2017 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 Jan  9  2017 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 Jan  9  2017 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   29 Jan  9  2017 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root   27 Jan  9  2017 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 Jan  9  2017 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   34 Jan  9  2017 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root   34 Jan  9  2017 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root   34 Jan  9  2017 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 Jan  9  2017 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   29 Feb  7  2019 php7.2.conf -> ../mods-available/php7.2.conf
lrwxrwxrwx 1 root root   29 Feb  7  2019 php7.2.load -> ../mods-available/php7.2.load
lrwxrwxrwx 1 root root   30 Jan  9  2017 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 Jan  9  2017 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 Jan  9  2017 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   36 Jan  4  2018 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root   26 Jan  4  2018 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root   26 Jan  4  2018 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root   29 Jan  9  2017 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 Jan  9  2017 status.load -> ../mods-available/status.load

手动备份wordpress目录

ubuntu@xxx:/var/www/html$ ll
total 36
drwxr-xr-x 4 root     root      4096 Sep  1 14:44 ./
drwxr-xr-x 3 root     root      4096 Jan  9  2017 ../
-rw-r--r-- 1 root     root     11510 Jan  9  2017 index.html
-rw-r--r-- 1 root     root       612 Feb  6  2019 index.nginx-debian.html
-rw-r--r-- 1 root     root        20 Jan  9  2017 phpinfo.php
drwxr-xr-x 5 www-data www-data  4096 Sep  1 14:02 wordpress/
drwxr-xr-x 5 www-data www-data  4096 Sep  1 14:44 wordpress-backup/

升级php版本

ubuntu 16.4版本需要添加临时repo[2]

sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
sudo apt-get update
sudo apt-get install php7.4
sudo apt-get install php7.4-mysql
php -v (check to make sure PHP 7.4 is installed)
sudo apt install php7.4-fpm php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-mysql php7.4-cli php7.4-zip php7.4-curl
sudo a2dismod php7.2
sudo a2enmod php7.4
sudo service apache2 restart

升级过程中,会提示安装建议

Processing triggers for php7.4-fpm (7.4.13-1+ubuntu16.04.1+deb.sury.org+1) ...
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
ubuntu@xxx:~$ ll /etc/apache2/mods-enabled/
total 8
drwxr-xr-x 2 root root 4096 Sep  1 14:58 ./
drwxr-xr-x 8 root root 4096 Jul 25 14:02 ../
lrwxrwxrwx 1 root root   36 Jan  9  2017 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root   28 Jan  9  2017 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 Jan  9  2017 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   33 Jan  9  2017 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 Jan  9  2017 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 Jan  9  2017 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   30 Jan  9  2017 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 Jan  9  2017 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 Jan  9  2017 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 Jan  9  2017 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 Jan  9  2017 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   29 Jan  9  2017 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root   27 Jan  9  2017 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 Jan  9  2017 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   34 Jan  9  2017 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root   34 Jan  9  2017 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root   34 Jan  9  2017 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 Jan  9  2017 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   29 Sep  1 14:58 php7.4.conf -> ../mods-available/php7.4.conf
lrwxrwxrwx 1 root root   29 Sep  1 14:58 php7.4.load -> ../mods-available/php7.4.load
lrwxrwxrwx 1 root root   30 Jan  9  2017 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 Jan  9  2017 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 Jan  9  2017 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   36 Jan  4  2018 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root   26 Jan  4  2018 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root   26 Jan  4  2018 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root   29 Jan  9  2017 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 Jan  9  2017 status.load -> ../mods-available/status.load

升级后验证

Reference

  1. https://wordpress.org/about/requirements/
  2. https://geek.ralpharama.co.uk/2023/01/05/cant-add-php-7-4-to-ubuntu-16-04/

发表评论