我添加了以下存储库条目/etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
然后运行安装命令yum --disablerepo=amzn-main --disablerepo=amzn-updates install nginx
出现此错误
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.17.1-1.el7.ngx will be installed
--> Processing Dependency: systemd for package: 1:nginx-1.17.1-1.el7.ngx.x86_64
--> Processing Dependency: systemd for package: 1:nginx-1.17.1-1.el7.ngx.x86_64
--> Processing Dependency: libpcre.so.1()(64bit) for package: 1:nginx-1.17.1-1.el7.ngx.x86_64
--> Finished Dependency Resolution
Error: Package: 1:nginx-1.17.1-1.el7.ngx.x86_64 (nginx)
Requires: systemd
Error: Package: 1:nginx-1.17.1-1.el7.ngx.x86_64 (nginx)
Requires: libpcre.so.1()(64bit)
这是最好的方法还是有人会建议其他方法?
答案1
这完全取决于您使用的是 Amazon Linux 1 (2018.03) 还是 Amazon Linux 2。
检查该/etc/os-release
文件以找出您拥有的是哪一个。
亚马逊Linux 1
/etc/os-release
包含:
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
适用于 Amazon Linux 1 的 AWS 存储库仅具有 nginx 版本 1.14.1:
0» yum info nginx
Loaded plugins: priorities, update-motd, upgrade-helper
1070 packages excluded due to repository priority protections
Available Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.14.1
Release : 2.34.amzn1
亚马逊Linux 2
/etc/os-release
包含:
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
在撰写本文时,AL2 只有 nginx 1.12.2:
» amazon-linux-extras list | grep nginx
4 nginx1.12 available [ =1.12.2 ]
安装库存版本
安装库存版本很容易。对于 AL1,执行yum install nginx
,对于 AL2 执行amazon-linux-extras install nginx1.12
。
自己编译一下
要运行 nginx 的尖端版本,您可能需要自己编译它或要求 AWS 更新其软件包。要自己编译 nginx,请参阅 Lee Benson 的精彩说明:https://stackoverflow.com/questions/37082406/how-to-install-nginx-1-9-15-on-amazon-linux-disto