示例1:
----------------------------------------------------------
server{
listen 80;
server_name www.aaa.com;
location / {
root /usr/share/nginx/aaa.com;
index index.html index.htm;
}
}
# mkdir /usr/share/nginx/aaa.com
# echo aaa >> /usr/share/nginx/aaa.com/index.html
示例2:
----------------------------------------------------------
server{
listen 80;
server_name www.bbb.com;
location / {
root /usr/share/nginx/bbb.com;
index index.html index.htm;
}
}
# mkdir /usr/share/nginx/bbb.com
# echo bbb >> /usr/share/nginx/bbb.com/index.html
结果测试:
----------------------------------------------------------
#在另一台客户端机器上修改hosts文件
echo "192.168.88.101 www.aaa.com" >> /etc/hosts
echo "192.168.88.102 www.bbb.com" >> /etc/hosts
#打开浏览器输入地址:www.aaa.com看看结果页面上显示的是否是aaa
#打开浏览器输入地址:www.bbb.com看看结果页面上显示的是否是bbb