深浅模式
使用官方仓库安装
安装 EPEL 仓库
首先,你需要安装 EPEL (Extra Packages for Enterprise Linux) 仓库,因为 Nginx 不在 CentOS 8 的默认仓库中。
bashsudo dnf install epel-release安装 Nginx
安装了 EPEL 仓库后,你可以直接使用
dnf命令来安装 Nginx。bashsudo dnf install nginx启动 Nginx 并设置开机启动
bashsudo systemctl start nginx sudo systemctl enable nginx sudo systemctl status nginx重新加载 Nginx 配置
bashsudo systemctl reload nginx默认配置路径
nginx.conf /etc/nginx/
error.log /var/log/nginx/error.log
验证安装
你可以通过访问服务器的 IP 地址来检查 Nginx 是否正确安装和运行。例如,在浏览器中访问
http://你的服务器IP