Nginx部署web

  1. 前端代码粘贴到服务器 例如:

2.到 /etc/nginx,新建 vhosts  (不用vhosts也可以,直接在nginx里面配置,但是好像不能同时使用80端口)

3.在vhosts里面新建几个.conf

4./etc/nginx/下的 nginx.conf,最下面,添加一句配置

include /etc/nginx/vhosts/*.conf;

这句的意思是: 引入 vhosts/里面的config

5.Vhosts 下的配置,比如am.conf

红框是重点

listen       80; //监听端口

server_name  am.dev.tuimu.com;  //域名

access_log  /var/log/nginx/am.log  main;  //log位置

index  index.html index.htm;   //指定index页面

location ^~/api { //把 server_name+/api这段指向接口(Tomcat里的项目)

proxy_pass http://10.50.96.29:8087/lieni-app-web-am/;

}

location ^~/ {  //前端代码所在目录,index.html同级

root   /deploy/www/lieni-www/web-am/src;

}

 

 

6.Host配置成nginx所在ip, 浏览器访问server_name. hr/hd等同理,可以用80端口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值