#配置虚拟主机aaa.test.com server { #监听的ip和端口,配置本机ip和端口 listen 192.168.78.132:80; #虚拟主机名称是aaa.test.com,请求域名aaa.test.com的url将由此server配置解析 server_name aaa.test.com; #所有的请求都以/开始,所有的请求都可以匹配此location location / { #使用root指令指定虚拟主机目录即网页存放目录 #比如访问http://ip/test.html将找到/usr/local/aaa_html/test.html #比如访问http://ip/item/test.html将找到/usr/local/aaa_html/item/test.html root /usr/local/aaa_html; #指定欢迎页面,按从左到右顺序查找 index index.html index.htm; } } #配置虚拟主机bbb.test.com server { listen 192.168.78.132:80; server_name bbb.test.com; location / { root /usr/local/bbb_html; index index.html index.htm; } }