查看CentOS版本:

cat /etc/redhat-release

安装nginx:

yum install nginx

查看nginx版本:

nginx -v

启动nginx:

systemctl start nginx

nginx默认发布目录:

cd /usr/share/nginx/

 

由于是单页应用虚拟路由的原因,需要将nginx的所有请求都转发到index.html页面,所以需要修改配置文件:

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location ~* html {
            rewrite .* /index.html break;
            root /usr/share/nginx/html/;
        }

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

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

 

相关文章:

  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-05-21
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2021-11-29
  • 2022-12-23
  • 2021-11-30
  • 2021-07-30
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案