nginx虚拟主机配置实例详解
nginx虚拟主机配置
server{
listen80;
server_namelocalhost;
location/{
roothtml;
indexindex.htmlindex.htm;
}
error_page404/404.html;
#redirectservererrorpagestothestaticpage/50x.html
#error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
}
配置说明:
listen80;=>指定虚拟主机监听的是80端口
server_namelocalhost;=>指定虚拟主机域名
location/{...}=>匹配请求路径,/表示匹配所有请求
roothtml;=>指定虚拟主机的物理根目录,eg、html物理根目录位于D:\div\nginx-1.9.14\html\
indexindex.htmlindex.htm;=>指定虚拟主机的默认首页,默认首页位于D:\div\nginx-1.9.14\html目录下
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!