配置如下:
http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; root html; index index.html; } server { listen 80; server_name www.test.com; } }打开:c:/windows/system32/drivers/etc/hosts文件
增加:127.0.0.1 www.test.com
打开浏览器输入:www.test.com就可访问到nginx的默认页面了
你可以把多个不同的虚拟主机配置文件include进来,如:
http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream jshop.360buy.com { server localhost:8080; } server { listen 80; server_name localhost; root html; index index.html; } include vhosts/www.test.com.conf; }