无法在 CentOS 中安装 PHP 包

无法在 CentOS 中安装 PHP 包

在 CentOS 6.3 中(编辑:更新到 6.4)我无法安装任何 PHP(MySQL 和许多其他)软件包。

例如输出yum install php-devel是:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.vit.com.tr
 * extras: mirrors.prometeus.net
 * rpmforge: mirror.nl.leaseweb.net
 * updates: mirrors.prometeus.net
Setting up Install Process
No package php-devel available.
Error: Nothing to do

输出ls /etc/yum.repos.d

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  mirrors-rpmforge  rpmforge.repo

grep -E "name|enabled" /etc/yum.repos.d/*:

/etc/yum.repos.d/CentOS-Base.repo:name=CentOS-$releasever - Base
/etc/yum.repos.d/CentOS-Base.repo:name=CentOS-$releasever - Updates
/etc/yum.repos.d/CentOS-Base.repo:name=CentOS-$releasever - Extras
/etc/yum.repos.d/CentOS-Base.repo:name=CentOS-$releasever - Plus
/etc/yum.repos.d/CentOS-Base.repo:enabled=0
/etc/yum.repos.d/CentOS-Base.repo:name=CentOS-$releasever - Contrib
/etc/yum.repos.d/CentOS-Base.repo:enabled=0
/etc/yum.repos.d/CentOS-Debuginfo.repo:name=CentOS-6 - Debuginfo
/etc/yum.repos.d/CentOS-Debuginfo.repo:enabled=0
/etc/yum.repos.d/CentOS-Media.repo:name=CentOS-$releasever - Media
/etc/yum.repos.d/CentOS-Media.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.0 - Base
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.0 - Updates
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.0 - Extras
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.0 - Contrib
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.0 - CentOSPlus
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.1 - Base
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.1 - Updates
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.1 - Extras
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.1 - Contrib
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.1 - CentOSPlus
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.2 - Base
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.2 - Updates
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.2 - Extras
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.2 - Contrib
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:name=CentOS-6.2 - CentOSPlus
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/rpmforge.repo:name = Red Hat Enterprise $releasever - RPMforge.net - dag
/etc/yum.repos.d/rpmforge.repo:enabled = 1

yum repolist:

repo id                                           repo name                                                                          status
base                                              CentOS-6 - Base                                                                      6,296+85
extras                                            CentOS-6 - Extras                                                                          13
rpmforge                                          Red Hat Enterprise 6 - RPMforge.net - dag                                          11,131+144
updates                                           CentOS-6 - Updates                                                                     890+34

yum list available 'php-*':

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.vit.com.tr
 * extras: mirrors.prometeus.net
 * rpmforge: www.mirrorservice.org
 * updates: mirrors.prometeus.net
Error: No matching Packages to list

所有 PHP 包都会发生这种情况。当我输入php-并按 Tab 键时,没有自动完成。有什么建议么?

答案1

某些软件(如 cpanel)禁用 php/etc/yum.conf

exclude= php*  mysql*

如果您的 /etc/yum.conf 文件包含上面的行,只需从该行中删除 php* 之后您就可以安装 php :)

答案2

从问题和输出来看,您似乎只启用了 RPMForge 存储库,仅此而已。

/etc/yum.repos.d/rpmforge.repo:name = Red Hat Enterprise $releasever - RPMforge.net - dag
/etc/yum.repos.d/rpmforge.repo:enabled = 1

所以运行:

# yum repolist disabled
repo id                                                            repo name
fedora/19/x86_64                                                   Fedora 19 - x86_64
fedora-debuginfo/19/x86_64                                         Fedora 19 - x86_64 - Debug
fedora-source/19/x86_64                                            Fedora 19 - Source
updates-debuginfo/19/x86_64                                        Fedora 19 - x86_64 - Updates - Debug
updates-testing/19/x86_64                                          Fedora 19 - x86_64 - Test Updates
updates-testing-debuginfo/19/x86_64                                Fedora 19 - x86_64 - Test Updates Debug
updates-testing-source/19/x86_64                                   Fedora 19 - Test Updates Source                 

现在启用所需的存储库: yum-config-manager --enable fedora-source

在你的情况下应该是base

答案3

bash 完成

我不相信yum当您默认按下该键时会执行自动完成tab。我发现这个 U&L 问答标题为:CentOS 6 中的 Yum 缺少 bash-completion 包,看来您需要安装该软件包bash-completion

$ sudo yum install bash-completion

重新抛光

我会利用 yum 的一些其他功能来确定发生了什么。对于初学者,您可以查看 yum 所了解的存储库:

$ yum repolist
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
repo id                    repo name                                      status
Dropbox                    Dropbox Repository                                  4
adobe-linux-i386           Adobe Systems Incorporated                         17
adobe-linux-x86_64         Adobe Systems Incorporated                          2
fedora                     Fedora 14 - x86_64                             22,161
google-chrome              google-chrome                                       3
google-earth               google-earth                                        1
google-talkplugin          google-talkplugin                                   1
lamolabs                   LamoLabs Repo                                      58
lamolabs-noarch            LamoLabs Repo                                       2
nautilus-flickr-uploader   Nautilus Flickr Uploader for Fedora 14              3
rpmfusion-free             RPM Fusion for Fedora 14 - Free                   411
rpmfusion-free-updates     RPM Fusion for Fedora 14 - Free - Updates         642
rpmfusion-nonfree          RPM Fusion for Fedora 14 - Nonfree                181
rpmfusion-nonfree-updates  RPM Fusion for Fedora 14 - Nonfree - Updates      282
scootersoftware            Scooter Software                                    1
updates                    Fedora 14 - x86_64 - Updates                    9,982
wuala                      cdn.wuala.com                                       8

可用列表

您还可以使用此命令查看您有权访问的存储库中可用的内容:

$ yum list available 'php-*'
php-mapi.x86_64                                     7.0.3-1.fc14         updates
php-mapserver.x86_64                                5.6.7-1.fc14         updates
php-markdown.noarch                                 1.0.1n-1.fc14        fedora·
php-mbstring.x86_64                                 5.3.8-3.fc14         updates
php-mcrypt.x86_64                                   5.3.8-3.fc14         updates
php-mssql.x86_64                                    5.3.8-3.fc14         updates
php-mysql.x86_64                                    5.3.8-3.fc14         updates
php-nusoap.noarch                                   0.9.5-1.fc14         fedora·
php-oauth.noarch                                    1.0-0.7.svn592.fc12  fedora·
php-odbc.x86_64                                     5.3.8-3.fc14         updates
...

搜索

您也可以使用以下命令搜索存储库:

$ yum search 'php-devel'
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
============================== Matched: php-devel ==============================
php-devel.x86_64 : Files needed for building PHP extensions
php-devel.i686 : Files needed for building PHP extensions
ice-php-devel.i686 : Tools for developing Ice applications in PHP
ice-php-devel.x86_64 : Tools for developing Ice applications in PHP

重新查询

如果您有权访问存储库来找出哪个存储库提供给定的包,则可以使用此工具:

$ repoquery php-devel
php-devel-0:5.3.3-22.el6.x86_64

$ repoquery -i php-devel

Name        : php-devel
Version     : 5.3.3
Release     : 22.el6
Architecture: x86_64
Size        : 3188116
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Group       : Development/Libraries
URL         : http://www.php.net/
Repository  : base
Summary     : Files needed for building PHP extensions
Source      : php-5.3.3-22.el6.src.rpm
Description :
The php-devel package contains the files needed for building PHP
extensions. If you need to compile your own PHP extensions, you will
need to install this package.

从上面我们可以看到该包php-devel正在从存储库中出来base

最快的镜子

有时这个插件可能会导致您的问题。您可以删除要使用的镜像的缓存,以便可以重新生成它。

$ locate timedhosts.txt
/var/cache/yum/x86_64/6/timedhosts.txt

$ sudo rm /var/cache/yum/x86_64/6/timedhosts.txt

然后再次运行 yum install php-devel 命令。

冗长的

上面提到的大多数命令都可以使用 switch--verbose-v。例如,您可以运行以下yum list available <pkg>命令来深入了解yum幕后实际执行的操作:

$ yum --verbose list available php-devel
Loading "fastestmirror" plugin
Loading "priorities" plugin
Loading "refresh-packagekit" plugin
Config time: 0.020
Yum Version: 3.2.29
Setting up Package Sacks
Loading mirror speeds from cached hostfile
 * base: mirror.thelinuxfix.com
 * epel: mirror.steadfast.net
 * extras: yum.singlehop.com
 * updates: ftpmirror.your.org
 --> python-netaddr-0.7.5-4.el6.noarch from base excluded (priority)
 --> python-tw-forms-0.9.9-1.el6.noarch from base excluded (priority)

 ...
 ...

 --> wxGTK-devel-2.8.12-1.el6.centos.x86_64 from extras excluded (priority)
73 packages excluded due to repository priority protections
pkgsack time: 6.174
rpmdb time: 0.000
Available Packages
php-devel.x86_64                        5.3.3-22.el6                        base

基础存储库被禁用?

在查看您运行的命令的输出时,您的基本存储库似乎已禁用 ( /etc/yum.repos.d/CentOS-Base.repo:enabled=0),需要启用它们。

您可以编辑这些文件并将行从 0 更改为 1,或者运行以下命令:

$ yum-config-manager --enable base
$ yum-config-manager --enable updates

启用所有存储库

您还可以尝试使用以下命令启用所有存储库:

$ yum --enablerepo=\* search php-devel

相关内容