常规安装
参考官网:https://nginx.org/en/linux_packages.html#Ubuntu
安装先决条件
1 | sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring |
导入官方 nginx 签名密钥,以便 apt 可以验证软件包的真实性。
1 | curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ |
验证下载的文件是否包含正确的密钥:
1 | gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg |
以稳定的 nginx 包设置 apt 存储库,请运行以下命令:
1 | echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \ |
使用主线 nginx 包,请运行以下命令:
1 | echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \ |
设置存储库固定,使我们的软件包优于发行版提供的软件包
1 | echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ |