1、Rocky Linux 9.4 安装 Nginx
1、更新软件包
$ sudo dnf upgrade --refresh -y
2、导入官方 Nginx 库
$ sudo tee /etc/yum.repos.d/nginx-mainline.repo<<EOF
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/9/x86_64/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
3、安装 dnf-utils
$ sudo dnf -y install dnf-utils
4、安装 Nginx
$ sudo dnf -y install nginx
6、配置防火墙
# 允许 HTTP
sudo firewall-cmd --permanent --zone=public --add-service=http
# 允许 HTTPS
sudo firewall-cmd --permanent --zone=public --add-service=https
# 重载防火墙
sudo firewall-cmd --reload
# 关闭防火墙
$ systemctl stop firewalld
# 禁止开机自启
$ systemctl disable firewalld
7、启动 Nginx
$ systemctl start nginx.service
# 设置开机启动
$ systemctl enable nginx
8、查看 Nginx 版本
$ nginx -v
nginx version: nginx/1.20.1
请登录后再评论