【发布时间】:2018-10-18 19:41:58
【问题描述】:
我正在尝试设置一个 Web 服务器来托管 Moodle,但在尝试安装 PHP7 时遇到了问题。
我目前正在使用 VirtualBox 来托管 CentOS 7.4。默认情况下,CentOS 随附 PHP 5.4.16。现在,根据我的阅读,从头开始升级和安装的选项是不同的。我曾尝试关注多个指导获取 PHP7 的站点,但没有运气。大多数指南告诉您安装两个存储库,Remi 和 EPEL。我遇到的主要问题是,每次我安装 epel 时,yum 要么中断,要么阻止我安装另一个包。
[root@localhost ~]# yum update
Loaded plugins: fastestmirror, langpacks
Could not retrieve mirrorlist http://mirrorlist.centos.org/?
release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
我尝试了很多方法来解决这个问题。一些主要的方法是:
yum clean all
yum --enablerepo=base clean metadata
rm -rf /var/cache/yum
我确实通过使用解决过这个问题一两次
yum --enablerepo=epel clean metadata
还有
sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
我知道我尝试过更多的方法,但我不记得所有的方法。这个故事的寓意是他们通常不会提供帮助。有时 yum 工作正常,我会运行 yum clean all,然后它会再次停止运行。
方法二:
我尝试的另一种方法是从他们各自的网站安装 rpm 包。我使用 WinSCP 将文件传输到我的虚拟机,然后使用 yum 安装它们。一切正常,我安装了 epel 和 remi。但随后 yum 无法正常工作。
有时它会安装软件包,但有些不会安装。我已经将 yum 超时值设置得更高,其他包也可以通过,但有些仍然没有。然后我清理了 yum 缓存,再次看到包含五个选项的消息。
方法三: 我从https://wiki.centos.org/HowTos/php7 找到了有关安装 PHP 7 的文档,我认为它必须有效,因为这是受支持的方式。
我一直跟着直到第一部分。
root @ centos7-vm: ~ # yum -y install centos-release-scl.noarch
我将收到错误消息,指出无法从镜像下载软件包,或者如果 yum 已经给我问题,它将显示清理 yum 的五个选项。
方法四:
从源代码构建 PHP 是我尝试的另一个选择。我导航到http://php.net/downloads.php 并下载了压缩包并使用 WinSCP 在我的机器上获取它。
我提取了文件,然后导航到 php 目录。
我尝试使用 ./configure 让事情顺利进行,但它说我需要 gcc。
我尝试使用 yum install gcc 安装 gcc,但无法安装所有软件包。
我创建了一个新的虚拟机并立即尝试安装 gcc,但仍然没有成功。
总结
有时我明白为什么 yum 不起作用,有时我会用头撞桌子。
是否有在 CentOS 上获取 PHP 7 的标准化方法?谁能链接一个准确的指南?
CentOS 自带 PHP 5.4 而不是 7 的原因是什么?
我觉得我几乎尝试了所有方法,但我知道有些网页我还没有找到。我想我今天做了所有我可能做的研究。
我确信我的问题结构可能不是最好的并且可能有点令人困惑,但我已经为此工作了大约 6-7 个小时。
这是我的第一篇文章,所以如果它不完美,我很抱歉。
【问题讨论】:
-
你是如何通过安装 php7 包来破坏 yum 的?我使用 IUS 的回购。百胜安装,一切顺利。
-
@ficuscr 我的想法完全...
-
我已经做到了,但是对 Python 进行了重大升级......
-
@importedtea,不是一个很好的 SO 问题...尝试另一个教程,它有一些简单的命令。如果您遇到更具体的问题,请再次询问。祝你好运!你会明白的。
-
为IUS加1,而你的yum问题与PHP无关,你的yum坏了。