如何在 Apache 运行时安装 Nginx?

如何在 Apache 运行时安装 Nginx?

我正在尝试安装 nginx 作为 Apache 的后端代理,但出现以下错误:

=== Install Nginx from official repositories ===
Loaded plugins: fastestmirror, remove-with-leaves, tsflags, universal-hooks
nginx                                                                                                                                                                                                                  | 2.9 kB  00:00:00
Loading mirror speeds from cached hostfile
 * EA4: 85.13.201.2
 * base: mirror0.babylon.network
 * elrepo: elrepo.reloumirrors.net
 * epel: mirror0.babylon.network
 * extras: mirror0.babylon.network
 * ius: mirror.amsiohosting.net
 * updates: mirror0.babylon.network
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.8.1-1.el7.ngx will be installed
--> Processing Conflict: ea-apache24-2.4.18-1.1.x86_64 conflicts webserver
--> Finished Dependency Resolution
Error: ea-apache24 conflicts with 1:nginx-1.8.1-1.el7.ngx.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我还尝试了 --skip-broken 它并不能帮助我得到这个:

root@panel [/]# yum install nginx --skip-broken
Loaded plugins: fastestmirror, remove-with-leaves, tsflags, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 85.13.201.2
 * base: mirror0.babylon.network
 * elrepo: elrepo.reloumirrors.net
 * epel: mirror0.babylon.network
 * extras: mirror0.babylon.network
 * ius: mirror.amsiohosting.net
 * updates: mirror0.babylon.network
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.8.1-1.el7.ngx will be installed
--> Processing Conflict: ea-apache24-2.4.18-1.1.x86_64 conflicts webserver

欢迎任何帮助。运行 CentOS 7。

答案1

Provides:标签与问题无关ea-apache24-2.4.18-1.1.x86_64 conflicts webserver。包 ea-apache24 有一个Conflicts: webserver导致此问题的标签。我认为这并不是很聪明,因为默认情况下几乎所有网络服务器都可以并行安装。不知道为什么你从一些外部存储库安装 apache,而你可以从基本 CentOS 存储库获得相同的内容而不会出现此类问题。

答案2

在你的情况下,我会从源代码构建 nginx。

这样做的优点是您可以仅启用作为代理运行所需的功能。

也有缺点。跟上安全问题成为您的责任,因此您必须跟踪 nginx 勘误表。此外,您还必须手动编写 init/systemd 启动脚本(尽管您可以从 RPM 中提取这些脚本并根据需要进行修改)。

如果您想保留通过包管理器管理它的能力,您始终可以将其打包为 RPM。网络上有大量的文档可以实现此目的,并且可以让您在不同的计算机上构建它,以防您的服务器缺乏开发环境。

顺便说一句,您可能已经知道这一点,但 Apache 也具有代理功能。 100% 使用 Apache(或 nginx)可能是一种选择。

答案3

绝对是不是可以覆盖它。请注意,切勿尝试--skip-broken

问题是 ea-apache24 与“webserver”明确冲突。 httpd 和 nginx 都提供“网络服务器”。因此,nginx 拒绝安装。如果不执行 则无法解决此问题rpm --force。但也有很大可能会失败。

这样做会造成 rpmdb 地狱。我建议不要这样做并删除 ea-apache24 然后安装 nginx。

相关内容