以下是官方给出的 nginx 安装步骤,详情可参考这里
安装依赖程序
apt install curl gnupg2 ca-certificates lsb-release -y
导入stable nginx 安装源
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list
设置安装源倾向性
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ | sudo tee /etc/apt/preferences.d/99nginx
导入nginx官方签名
curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key
验证下载的文件是否包含正确的密钥
gpg --dry-run --quiet --import --import-options show-only /tmp/nginx_signing.key
输出如下指纹信息则正确:573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14] 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 uid nginx signing key <signing-key@nginx.com>
最后,将密钥移动到 apt 可信密钥存储(注意“asc”文件扩展名更改):
mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
安装nginx
apt update apt install nginx -y
设置nginx开机自动启动
systemctl enable nginx
文章评论