nginx虚拟主机配置实例详解

(编辑:jimmy 日期: 2024/9/22 浏览:2)

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目录下

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。