nginx虚拟主机配置
Posted Ruthless
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx虚拟主机配置相关的知识,希望对你有一定的参考价值。
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
# error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
配置说明:
listen 80; =>指定虚拟主机监听的是80端口
server_name localhost; =>指定虚拟主机域名
location / { ... } =>匹配请求路径,/表示匹配所有请求
root html; =>指定虚拟主机的物理根目录,eg、html物理根目录位于D:\div\nginx-1.9.14\html\
index index.html index.htm; =>指定虚拟主机的默认首页,默认首页位于D:\div\nginx-1.9.14\html目录下
以上是关于nginx虚拟主机配置的主要内容,如果未能解决你的问题,请参考以下文章
Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段