当要部署多个web程序时,先将web程序分文件夹到html,
1 在conf目录下新建conf-test/test_web.conf
内容为:
server {
listen 80;
server_name webone.com;
location / {
root html/web1;
index index.html index.htm;
}
}
server {
listen 80;
server_name webtwo.com;
location / {
root html/web2;
index index.html index.htm;
}
}
server {
listen 80;
server_name webthree.com;
location / {
root html/web3;
index index.html index.htm;
}
}
2 在nginx.conf中引入该配置文件 include conf-test/*.conf;
4 找到hosts文件, C:\Windows\System32\drivers\etc
增加
127.0.0.1 webone.com
127.0.0.1 webtwo.com
127.0.0.1 webthree.com
再重新启动nginx taskkill /fi "imagename eq nginx.EXE" /f