NGINX安装
作者:互联网
NGINX 笔记
NGINX安装
官方下载地址 https://nginx.org/en/download.html
官方安装帮助文档 http://nginx.org/en/linux_packages.html#distributions
RHEL/Centos
版本 | 支持平台 |
---|---|
7.4+ | x86_64, ppc64le, aarch64/arm64 |
8.x | x86_64, aarch64/arm64, s390x |
安装依赖
sudo yum install yum-utils
创建文件 /etc/yum.repos.d/nginx.repo
touch /etc/yum.repos.d/nginx.repo
vim 编辑
vim /etc/yum.repos.d/nginx.repo
拷贝以下内容到 /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
默认情况下,使用稳定 nginx 包的存储库。如果你想使用主线 nginx 包,运行以下命令:
sudo yum-config-manager --enable nginx-mainline
安装 nginx
sudo yum install nginx
启动 nginx
nginx
查看 nginx 安装目录和文件位置
rpm -ql nginx
Debian
版本 | 支持平台 |
---|---|
10.x “buster” | x86_64, i386, aarch64/arm64 |
11.x “bullseye” | x86_64, aarch64/arm64 |
安装依赖
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring
导入官方的 nginx 签名密钥,以便 apt 能够验证包的真实性:
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
确认下载的文件包含正确的密钥:
gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
输出应包含完整指纹573bfd6b3d8fbc641079a6abf5bd827bd9bf62,详情如下:
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>
stable nginx 包建立 apt 库,运行以下命令:
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
如果你想使用主线 nginx 包,可以运行以下命令:
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `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
sudo apt update
sudo apt install nginx
启动 nginx
nginx
查看 nginx 安装目录和文件位置
dpkg -L nginx
Ubuntu
版本 | 支持平台 |
---|---|
18.04 “bionic” | x86_64, aarch64/arm64 |
20.04 “focal” | x86_64, aarch64/arm64, s390x |
21.10 “impish” | x86_64, aarch64/arm64 |
安装依赖
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
导入官方的 nginx 签名密钥,以便 apt 能够验证包的真实性:
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
确认下载的文件包含正确的密钥:
gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
输出应包含完整指纹 573bfd6b3d8fbc641079a6abf5bd827bd9bf62,详情如下:
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>
要为 stable nginx 包建立 apt 库,运行以下命令:
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
如果你想使用主线 nginx 包,可以运行以下命令:
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/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
sudo apt update
sudo apt install nginx
启动 nginx
nginx
查看 nginx 安装目录和文件位置
dpkg -L nginx
标签:gpg,nginx,--,sudo,apt,NGINX,org,安装 来源: https://www.cnblogs.com/lindaotan/p/15902661.html