nginx配置前端网站

主要是改

location / {
     root   html;
     index  index.html index.htm;
}

 

这表示默认的网站是nginx的html文件夹。

假如我们写的前端项目文件打包后是dist。我们把这个dist文件夹放在nginx目录下,然后修改为:

location / {
root dits;
index index.html index.htm;
}

这样就可以访问我们的前端文件了。

2.配置启动
如果要重启,或者停止服务都必须在dos命令下手动重启或停止,比较麻烦,我用批处理写了重启和停止命令:如下

stop.bat

@echo off
 
cd %~dp0
 
nginx -s quit

 

restart.bat

@echo off
 
cd %~dp0
 
nginx -s reload
 
 
posted @ 2022-09-24 22:53  霸气小青年  阅读(102)  评论(0编辑  收藏  举报