1、Nginx配置文件结构
之前便讲过,默认的Nginx配置文件存放在安装目录conf中,主配置文件为nginx.conf,默认的配置文件是比较复杂,不过结构和内容还是比较清晰,在此简化出一个最基本的配置:
#全局区域
worker_processes 1; #全局区域
#events区域
events {
worker_connections 1024;
}
#http区域
http {
include mine.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#server区域
server {
listen 80;
server_name localhost;
#location区域
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
从上面的配置文件内容,我们可以归纳nginx.conf的基本结构为:
#全局区域
#events区域
events {
}
#http区域
http {
#server区域
server {
#location区域
location [PATTERN] {
...
}