惊雷无声 发表于 2024-10-1 06:48:55

用nginx部署两个前端(超简单,三步!)

1.首先在nginx的html目录下创两个文件夹分别用于放两个前端打包好的静态资源,而且把静态资源各自放好:
https://i-blog.csdnimg.cn/blog_migrate/2e9f81a4ec59bf3abe31ed12e9a696b9.png
2. 在nginx的配置文件里,写好两个server。如图,写好两个前端要用的端口以及刚才那两文件夹的路径:
https://i-blog.csdnimg.cn/blog_migrate/194ce4c466a256c23423fd2c25252e18.png

worker_processes1;
events {
    worker_connections1024;
}
http {
    include       mime.types;
    default_typeapplication/octet-stream;
    server {
      listen       8081;
      server_namelocalhost;
      location / {
            root   html/manage;
            indexindex.html index.htm;
      }   
      error_page   500 502 503 504/50x.html;
      location = /50x.html {
            root   html;
      }
    }
server {
      listen       8082;
      server_namelocalhost;
      location / {
            root   html/client;
            indexindex.html index.htm;
      }
      error_page   500 502 503 504/50x.html;
      location = /50x.html {
            root   html;
      }
    }
}
3. 再双击一下nginx.exe就可以了: 
https://i-blog.csdnimg.cn/blog_migrate/de4dc2e9db7a0321461a06ea35145f40.png
https://i-blog.csdnimg.cn/blog_migrate/c5293e00f89055d3034b5f5cd4b0b2d6.png
 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 用nginx部署两个前端(超简单,三步!)