Windows for Nginx部署Vue项目

Windows端口占用处理

## 查看指定端口是否被占用
netstat -aon|findstr "8081"

## 根据PID杀死进程
taskkill /T /F /PID 9088 


配置Nignx

注:项目路径中不能有中文;

注:浏览器会缓存前端页面或资源,修改配置后请强刷页面;

注:Windows下的nginx配置文件必须是utf-8编码,其他编码都不行,utf-8 bom也不行;非utf-8编码会导致nginx报一些奇怪的错误;

server {
   listen       80;
   server_name  _;   
   
   location / {
      root   html;
      index  index.html index.htm;
   }
   
   # Vue项目1
   location /mcnp-management {
      alias  webroot/mcnp-management;          
      try_files $uri $uri/ /index.html last;
      index  index.html index.htm;
   }

   # Vue项目2
   location /mcnp-client {
      alias  webroot/mcnp-client;          
      try_files $uri $uri/ /index_ct.html last;
      index  index_ct.html;
   }

   # 普通静态资源项目
   location /map {
      alias  webroot/china-electronic-map-10level;          
      index  index.html index.htm;
   }

   # ....
}


Nginx开机自启

将Nginx快捷方式放置到如下文件夹中:

C:\Users\用户名\AppData
oaming\Microsoft\Windows\Start Menu\Programs\Startup


举报

© 著作权归作者所有


0