无法在 CentOS 上安装 PHP 软件包

Can't install PHP Package on CentOS

我在由 digital ocean 托管的服务器上通过 yum 重新安装 PHP 时遇到问题。

我安装了 PHP 5.4,但想要 5.6。我 added/enabled remi repo 的 运行 yum -y remove php* 然后尝试重新安装 php.

当我 运行 yum -y install php 我得到以下信息:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.centos.webair.com
 * epel: mirrors.coreix.net
 * extras: mirrors.centos.webair.com
 * remi: remi.check-update.co.uk
 * remi-php56: remi.check-update.co.uk
 * updates: mirrors.centos.webair.com
 * webtatic: uk.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.6.8-1.el6.remi will be installed
--> Processing Dependency: php-common(x86-64) = 5.6.8-1.el6.remi for package: php-5.6.8-1.el6.remi.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.6.8-1.el6.remi for package: php-5.6.8-1.el6.remi.x86_64
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.6.8-1.el6.remi.x86_64
--> Running transaction check
---> Package php.x86_64 0:5.6.8-1.el6.remi will be installed
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.6.8-1.el6.remi.x86_64
---> Package php-cli.x86_64 0:5.6.8-1.el6.remi will be installed
---> Package php-common.x86_64 0:5.6.8-1.el6.remi will be installed
--> Processing Dependency: php-pecl-zip(x86-64) for package: php-common-5.6.8-1.el6.remi.x86_64
--> Processing Dependency: php-pecl-jsonc(x86-64) for package: php-common-5.6.8-1.el6.remi.x86_64
--> Running transaction check
---> Package php.x86_64 0:5.6.8-1.el6.remi will be installed
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.6.8-1.el6.remi.x86_64
---> Package php-pecl-jsonc.x86_64 0:1.3.7-1.el6.remi.5.6 will be installed
---> Package php-pecl-zip.x86_64 0:1.12.5-1.el6.remi.5.6 will be installed
--> Finished Dependency Resolution
Error: Package: php-5.6.8-1.el6.remi.x86_64 (remi-php56)
           Requires: httpd-mmn = 20051115
           Installed: httpd-2.4.6-31.el7.centos.x86_64 (@base)
               httpd-mmn = 20120211
               httpd-mmn = 20120211x8664
               httpd-mmn = 20120211-x86-64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我一直在关注this tutorial

我有点卡住了。我试过删除 httpd,重新安装 httpd,似乎没有什么可以解决这个问题。当我禁用 remi 并尝试安装 PHP 5.4.

时,我什至会收到错误消息

关于从这里到哪里去的任何想法?

我是 运行ning CentOS Linux 版本 7.1.1503(核心)

虽然这可能更适合 serverfault 或 poweruser,但我还是会回答。

这是根据经验得出的,如果按照指示进行,每次都有效。

To install, first you must add the Webtatic EL yum repository information corresponding to your CentOS/RHEL version to yum:

CentOS/RHEL 7.x:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

然后您可以像这样安装每个单独的软件包:

yum install php56w-<package name>

不过不要忘记 php56w 前缀。

来源:https://webtatic.com/packages/php56/


试试这个(关于评论):

yum update -y; yum remove httpd && yum install httpd; yum install php56w-common php56w-opcache php56w-mysql

我修好了!问题是我安装了错误版本的 EL。 我删除了所有额外的回购,删除了所有 php 包,删除了 httpd. 运行 以下:

yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum clean
yum update

然后我可以使用以下

安装PHP
yum install php56w php56w-opcache php56w-mcrypt php56w-pdo php56w-mysql

我在 linux 机器上安装 php70w(webstatic) 时也遇到了同样的问题。以下命令帮助我安装 php70

sudo yum clean all   // to clear all caches

清除缓存后再次安装 php70 使用:

sudo yum install php70