Skip to content

使用官方仓库安装 ​

  1. 安装 EPEL 仓库

    首先,你需要安装 EPEL (Extra Packages for Enterprise Linux) 仓库,因为 Nginx 不在 CentOS 8 的默认仓库中。

    bash
    sudo dnf install epel-release
  2. 安装 Nginx

    安装了 EPEL 仓库后,你可以直接使用 dnf 命令来安装 Nginx。

    bash
    sudo dnf install nginx
  3. 启动 Nginx 并设置开机启动

    bash
    sudo systemctl start nginx
    sudo systemctl enable nginx
    sudo systemctl status nginx
  4. 重新加载 Nginx 配置

    bash
    sudo systemctl reload nginx
  5. 默认配置路径

    nginx.conf /etc/nginx/

    error.log /var/log/nginx/error.log

  6. 验证安装

    你可以通过访问服务器的 IP 地址来检查 Nginx 是否正确安装和运行。例如,在浏览器中访问 http://你的服务器IP

China SmallGu Blog