NGINX安装
2022/2/17 7:11:43
本文主要是介绍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
这篇关于NGINX安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-13用Nginx防范DDoS攻击的那些事儿
- 2024-12-13用Terraform在AWS上搭建简单NGINX服务器指南
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享