在centos 7上完成php的卸载和重新安装

zpf6vheq  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(427)

我需要在centos 7上尝试PHP5.6和5.5。所以,我把它们安装在了php7.1的完美安装之上。我按照这里的说明:https://www.mojowill.com/geek/howto-install-php-5-4-5-5-or-5-6-on-centos-6-and-centos-7/
基本上,我编辑了remi repo config文件以启用php5.6和5.5,并安装了php5.6。我测试了我想测试的内容,并尝试通过禁用repos和卸载所有php,然后重新安装来切换回来。现在我有问题了。
以下是症状和我尝试过的。
我收到一条关于wordpress安装的消息” Your PHP installation appears to be missing the MySQL extension which is required by WordPress. "


# php -v

PHP**7.2.14**(cli) (built: Jan  8 2019 14:05:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group

<? phpinfo() ?> works but says php version**7.1.24**

我尝试检查是否仍安装了php mysql:


# yum list installed | grep php

php.x86_64                              7.2.14-1.el7.remi              @remi-php72
php-cli.x86_64                          7.2.14-1.el7.remi              @remi-php72
php-common.x86_64                       7.2.14-1.el7.remi              @remi-php72
php-gd.x86_64                           7.2.14-1.el7.remi              @remi-php72
php-json.x86_64                         7.2.14-1.el7.remi              @remi-php72
php-mysqlnd.x86_64                      7.2.14-1.el7.remi              @remi-php72
php-pdo.x86_64                          7.2.14-1.el7.remi              @remi-php72
php-pecl-mcrypt.x86_64                  1.0.1-6.el7.remi.7.2           @remi-php72

# yum install php-mysql

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.layeronline.com
 * epel: mirror.uic.edu
 * extras: centos.mirror.globo.tech
 * nux-dextop: mirror.li.nux.ro
 * remi: repo1.ash.innoscale.net
 * remi-php72: repo1.ash.innoscale.net
 * remi-safe: repo1.ash.innoscale.net
 * updates: centos.mirror.ca.planethoster.net
 * webtatic: us-east.repo.webtatic.com
Package php-mysql-5.4.45-16.el7.remi.x86_64 is obsoleted by php-mysqlnd-7.2.14-1.el7.remi.x86_64 which is already installed

有没有什么简单的解决方法,或者我应该重新安装整个开发机器。

xienkqul

xienkqul1#

首先删除所有关于旧php版本的内容(需要一些时间…)

sudo yum remove --setopt=clean_requirements_on_remove=1 php php-pear php-mysql php-cli php-common mod-php

然后,安装新版本(需要更多时间)

sudo yum install mod_php70u php70u-cli php70u-mysqlnd

别忘了重新启动并检查sudo apachectl restart systemctl status httpd
如果您使用nginx运行fpm,那么请使用以下卸载(这将保留配置的权限以删除包/依赖项)

sudo yum remove --setopt=clean_requirements_on_remove=1 php-fpm php-cli php-common php7-fpm php7-cli php7-common

安装

sudo yum install php7-fpm-nginx php7-cli php7-mysqlnd

(如果需要,请使用[72]而不是[7])
保存、退出并重新启动

sudo systemctl restart php-fpm
    sudo systemctl restart nginx #(or whatever you use)

请考虑升级到7.1版本,因为与最新版本相比,连接模块的痛苦可能会小一些,尤其是在总是有问题的centos上
(感谢@fyrye提供删除选项)

相关问题