原文:https://book.2cto.com/201304/19625.html
nginx的配置文件其实是一个普通的文本文件。下面来看一个简单的例子。
user nobody;
worker_processes 8;
error_log /var/log/nginx/error.log error;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 50000;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr [$time_local] "$request" ‘
‘$status $bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
access_log logs/access.log main buffer=32k;
…
}
在这段简短的配置代码中,每一行配置项的语法格式都将在2.2.2节介绍,出现的events和http块配置项将在2.2.1节介绍,以#符号开头的注释将在2.2.3节介绍,类似“buffer=32k”这样的配置项的单位将在2.2.4节介绍。