问题描述:

腾讯云OpenCloudOS 9系统下使用yum安装ngnix时报错

1
2
3
4
5
6
7
[root@VM-4-7-opencloudos /]# yum install nginx -y
Last metadata expiration check: 0:00:41 ago on Mon 14 Apr 2025 01:01:27 AM CST.
Error:
Problem: cannot install the best candidate for the job
- nothing provides libcrypt.so.2()(64bit) needed by nginx-2:1.26.3-1.el9.ngx.x86_64 from nginx-stable
- nothing provides libcrypt.so.2(XCRYPT_2.0)(64bit) needed by nginx-2:1.26.3-1.el9.ngx.x86_64 from nginx-stable
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

解决方法:

--nobest 选项尝试安装不那么新的 nginx

1
sudo yum install nginx --nobest -y
1
2
3
4
Installed:
nginx-1.26.2-2.oc9.ap.2.x86_64 nginx-core-1.26.2-2.oc9.ap.2.x86_64 nginx-filesystem-1.26.2-2.oc9.ap.2.noarch system-logos-httpd-1.0.4-1.oc9.noarch
Skipped:
nginx-2:1.26.3-1.el9.ngx.x86_64

这个选项会跳过“最佳匹配”版本,可能会选一个不依赖 libcrypt.so.2 的旧版 nginx。

包名版本 提供方 说明
nginx-1.26.2-2.oc9.ap.2 OpenCloudOS 社区 为 oc9 系统构建,兼容性更好
nginx-1.26.3-1.el9.ngx NGINX 官方 最新稳定版,但可能依赖更新的系统库(比如 libcrypt.so.2