Nginx的基本配置
默认的Nginx配置文件
# 全局块
user nginx; # 设置用户以及用户组
worker_processes 1; # 工作进程的数量
error_log /var/log/nginx/error.log warn; # 错误日志
pid /var/run/nginx.pid; # pid文件位置
# events块
events {
worker_connections 1024; # 每个进程允许的最大连接数
}
# http块
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# 访问日志
access_log /var/log/nginx/access.log main;
# sendfile 零拷贝机制开关
sendfile on;
#tcp_nopush on;
# 客户端与服务端的超时时间,单位s
keepalive_timeout 65;
#gzip on;
# 这里,导入了conf.d中所有的配置, 默认包含一个default.conf文件
include /etc/nginx/conf.d/*.conf;
}配置块说明
日志配置
日志切割
虚拟主机配置
location匹配规则
匹配符号
含义
常用的匹配规则
配置文件详解
最后更新于