9

CentOS PHP版本从7.0升级到7.4

 3 years ago
source link: https://www.deaboway.com/centos-php%e7%89%88%e6%9c%ac%e4%bb%8e7-0%e5%8d%87%e7%ba%a7%e5%88%b07-4.html#.X99QcRMRWo8
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

包子啥汤

no Pain no Gain no Gavin

CentOS PHP版本从7.0升级到7.4

QQ20200729-173407.png

WordPress提示说当前使用的php版本不安全,升级以后更安全性能更好,那就升级一下吧!

yum clean all
yum update

  1. 更换PHP源

如果之前是5.X版本的php,则需要:

php高版本的yum源地址,有两部分,其中一部分是epel-release,另外一部分来自webtatic。如果跳过epel-release的话,安装webtatic的时候

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm

我原来用的webtatic的源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
因此需要删掉

sudo yum remove webtatic-release -y
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm

  1. 删除现有的PHP
    yum remove php php-* php70*
  2. 安装PHP 7.4
    yum –enablerepo=remi-php74 install php
  3. 安装PHP组件
    yum –enablerepo=remi-php74 install php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd

更多组件信息可通过以下命名查看:
yum –enablerepo=remi-php74 search php | grep php74

yum –enablerepo=remi-php74 install php74-php-fpm
yum –enablerepo=remi-php74 install php74-php-mysql

  1. 启动PHP-FPM
    运行并查看版本
    php -v
    重启命令php-fpm
    systemctl restart php74-php-fpm
    添加自动启动
    systemctl enable php74-php-fpm
    查看php7.4的安装路径
    whereis php

如果安装之后是php74,则需要链接php文件
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

  1. 重启apache
    systemctl restart httpd
    systemctl restart nginx
  2. 其它问题:
    【您的PHP似乎没有安装运行WordPress所必需的MySQL扩展解决办法】
    如果您是英文网站,那么显示的就是: Fatal Error: ezSQL_mysql requires mySQL Lib to be compiled and or linked in to the PHP engine 。
    这个问题的出现可能原因是:
    服务器升级了较高的PHP版本,但是WordPress还是在使用较老的版本。
    解决办法:到WordPress.org官网下载最新版的WordPress程序,通过ftp,覆盖之前的程序就行。

如果还不行,就要看下配置文件:
vi /etc/php.ini
vi /etc/opt/remi/php74/php.ini

发现php7.4根目录在:
/etc/opt/remi/php74/

进入配置文件目录:
cd /etc/opt/remi/php74/php.d

QQ20200729-183511.png

发现需要修改之前旧的配置文件:
vim 50-mysql.ini
通过查找发现,更新内容:
extension = mysql.so 为:
extension = pdo_mysql
对应的so库都在如下目录:
cd /usr/lib64/php/modules/

QQ20200729-184125.png

更简单的方法,直接删除多余的配置文件
rm 50-mysql.ini

重启命令php-fpm
systemctl restart php74-php-fpm

  1. 发现如下错误:
    https://www.deaboway.com/wp-admin/site-health.php
    警告 可选的模组dom未被安装或已被禁用。
    警告 可选的模组mbstring未被安装或已被禁用。
    警告 可选的模组imagick未被安装或已被禁用。
    警告 可选的模组zip未被安装或已被禁用。
    错误 必需的模组gd未被安装或已被禁用。
QQ20200729-184831.png

使用rpm -qal | grep gd.so命令,定位到gd.so的位置
rpm -qal | grep gd.so

本质上还是一些扩展没有安装,运行如下命令:
yum –enablerepo=remi-php74 install php74-php-gd php74-php-pecl-zip php74-php-mbstring php74-php-pecl-imagick
yum –enablerepo=remi-php74 install php74-php-dom

重启命令php-fpm
systemctl restart php74-php-fpm

  1. 您的站点遇到了致命错误。

开启WordPress调试模式:
// 开启WP_DEBUG模式 下面的true改为false可以关掉调试模式
define( ‘WP_DEBUG’, true );

// 开启DEBUG日志,一定要记得关闭这个日志功能并清理这个日志文件哦,产生的日志文件在: /wp-content/debug.log
define( ‘WP_DEBUG_LOG’, true );

// 显示errors and warnings
define( ‘WP_DEBUG_DISPLAY’, true );
@ini_set( ‘display_errors’, ‘On’ );

add_submenu_page的调用方法不正确。传给add_submenu_page()的第七个参数应该是代表菜单位置的整数。 请查阅 https://wordpress.org/support/article/debugging-in-wordpress/ 调试WordPress
/usr/share/nginx/dea/wp-includes/functions.php on line 5167

Notice: Undefined offset: 0 in /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 532

Fatal error: Uncaught Error: Call to a member function id() on array in /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php:36 Stack trace: #0 /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php(538): CrayonFormatter::format_code() #1 [internal function]: CrayonFormatter::delim_to_internal() #2 /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php(516): preg_replace_callback() #3 /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_highlighter.class.php(166): CrayonFormatter::format_mixed_code() #4 /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_highlighter.class.php(186): CrayonHighlighter->process() #5 /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php(703): CrayonHighlighter->output() #6 /usr/share/nginx/dea/wp-includes/class-wp-hook.php(287): CrayonWP::the_content() #7 /usr/share/nginx/dea/wp-includes/plugin.php(206): WP in /usr/share/nginx/dea/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 36‘

暂时只能禁用掉crayon-syntax-highlighter插件

参考:
https://www.cnblogs.com/alliancehacker/p/12255445.html
https://www.biaodianfu.com/php-update.html
https://www.wopus.org/wordpress-troubleshooting/6467.html?wpzmaction=add&postid=6467
https://www.deaboway.com/gavtest.php
https://www.wpyi.com/zhiming-cuowu.html

欢迎关注我的微信公众号:

qrcwechat.jpg

如无特殊说明,文章均为本站原创,转载请注明出处!

e6578c0c30a337e335cd5d2dbc3f2836?s=49&d=monsterid&r=g作者 deaboway发布于 2020年7月29日2020年8月7日分类 1. 全栈开发标签 wordpress

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK