http { # 第一个虚拟主机 server { # 监听的端口 listen 80; # 主机名称 server_name aaa.domain.com; # 访问日志文件存放路径 access_log logs/aaa.domain.com.access.log combined; location / { # 默认首页文件,顺序从左到右,如果找不到index.html文件,则查找index.htm文件作为首页文件 index index.html index.htm; # HTML网页文件存放的目录 root /data0/htdocs/aaa.domain.com; } } # 第二个虚拟主机 server { # 监听的IP和端口 listen 80; # 主机名称 server_name bbb.otherdomain.com; # 访问日志文件存放路径 access_log logs/bbb.otherdomain.com.access.log combined; location / { # 默认首页文件,顺序从左到右,如果找不到index.html文件,则查找index.htm文件作为首页文件 index index.html index.htm; # HTML网页文件存放的目录 root /data0/htdocs/bbb.otherdomain.com; } } # 第三个虚拟主机 server { # 监听的IP和端口 listen 80; # 主机名称 server_name www.domain.com domain.com *.domain.com; # 访问日志文件存放路径 access_log logs/bbb.domain.com.access.log combined; location / { # 默认首页文件,顺序从左到右,如果找不到index.html文件,则查找index.htm文件作为首页文件 index index.html index.htm; # HTML网页文件存放的目录 root /data0/htdocs/domain.com; } } }