nginx虛擬主機(jī)配置
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; =>指定虛擬主機(jī)監(jiān)聽的是80端口
server_name localhost; =>指定虛擬主機(jī)域名
location / { ... } =>匹配請(qǐng)求路徑,/表示匹配所有請(qǐng)求
root html; =>指定虛擬主機(jī)的物理根目錄,eg、html物理根目錄位于D:/div/nginx-1.9.14/html/
index index.html index.htm; =>指定虛擬主機(jī)的默認(rèn)首頁,默認(rèn)首頁位于D:/div/nginx-1.9.14/html目錄下