标签:
一、通过端口创建虚拟主机
vim /usr/local/tengine-2.1.0/conf/nginx.conf # 添加两个Server,一个Server的端口指向80 server { listen 80; server_name 192.168.163.11; location / { root html; index index.html index.htm; } } #另一个的端口指向8080 server { listen 8080; server_name 192.168.163.11; location / { root /opt/sxt/html; index index.html index.htm; } } #然后重启Nginx service nginx restart
ifconfig eth0:1 192.168.163.100(虚拟IP,但一定要和真实IP在同一个网段) netmask 255.255.255.0 ifconfig #查看新虚拟出来的IP #两个Server监听两个不同的IP server { listen 80; server_name 192.168.163.11; location / { root html; index index.html index.htm; } } server { listen 80; server_name 192.168.163.100; location / { root /opt/sxt/html; index index.html index.htm; } }
#将两个域名指向同一个端口,访问结果是什么 server { listen 80; server_name www.nginx1.com; location / { root html; index index.html index.htm; } } server { listen 80; server_name www.nginx2.com; location / { root /opt/sxt/html; index index.html index.htm; } }
标签:
原文地址:http://www.cnblogs.com/raphael5200/p/5122684.html