• 安装nginx
yum install  -y nginx
#如果报错 安装epel**
yum install -y epel-release 
#epel不存在安装
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm  
rpm -Uvh https://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.20.1-1.el8.ngx.x86_64.rpm

#启动
systemctl start nginx 
#重启
systemctl restart nginx
#开机启动
systemctl enable nginx
  • 配置 /etc/nginx/nginx.conf

#添加网站

/etc/nginx/conf.d/*.conf
server {
    listen       8020;
    #listen       [::]:8020;
    server_name  _;
    root         /data/webTest;

    error_page 404 /404.html;
    location = /404.html {
    }
}