Debian12安装最新版本nginx

服务器技术 5 个月前 回复

,

序言

Debian12的源里nginx最大版本只支持到1.22,所以想安装最新版nginx,可以参考官方文档。

安装步骤

1、安装依赖库

apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring

2、导入key密钥

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

3、验证密钥

gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

4、 输出密钥指纹 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 如下:

pub rsa2048 2011-08-19 [SC] [expires: 2027-05-24]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key

5、设置版本
5.1 稳定版本源

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
    | tee /etc/apt/sources.list.d/nginx.list

5.2 主线版本源

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \
    | tee /etc/apt/sources.list.d/nginx.list

6、设置库

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | tee /etc/apt/preferences.d/99nginx

7、更新库并且安装

apt update && apt install nginx

参考文章:http://nginx.org/en/linux_packages.html#Debian

支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

发表评论

欢迎回来 (打开)

(必填)