nginx.conf 配置
时间: 2023-06-26 17:07:51 浏览: 29
下面是一个简单的nginx.conf配置文件示例:
```
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
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 on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
}
```
其中,`user`指定了nginx进程运行的用户;`worker_processes`指定了worker进程的数量,`auto`表示根据系统自动选择;`error_log`指定了错误日志文件路径;`pid`指定了pid文件路径;
`events`块中指定了worker进程的最大连接数。
`http`块是主要的HTTP配置,包括了MIME类型、默认类型、日志格式、访问日志路径、文件发送方式、TCP拓展、保持连接时间、gzip压缩等配置。`include`语句可以将其他的配置文件包含进来,以便更好地组织和管理配置。
`/etc/nginx/conf.d/*.conf`则是一个通配符,表示将`/etc/nginx/conf.d/`目录下所有以`.conf`结尾的文件都包含进来。这里可以将不同的虚拟主机或其他配置分别写在不同的文件中,以便管理和维护。
相关推荐















