目录


pidusererror_logworker_connectionsincludehttpserver


nginx主配置文件中的内容

pid

主线程id的存储位置。

# cat /usr/local/nginx/logs/nginx.pid
1113
# pgrep -o nginx
1113

user

使用这个参数来配置 worker 进程的用户和组。如果忽略 group ,那么group 的名 字等于该参数指定用户的用户组。

# ps -ef | grep nginx
root 1113 1 0 12月08 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 1118 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1119 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1120 1113 0 12月08 ? 00:00:00 nginx: worker process
www 1121 1113 0 12月08 ? 00:00:01 nginx: worker process

error_log

错误日志的位置。

worker_connections

该指令配置一个工作进程能够接受并发连接的最大数。

include

在 Nginx 的配置文件中, include 文件可以在任何地方,以便增强配置文件的可读性,并且能够使得部分配置文件重新使用。

include vhost/*.conf;

http

include       mime.types; #文件扩展名与文件类型映射表
default_type application/octet-stream; #默认文件类型
sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来 输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置 为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常 把这个改成off。
autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
tcp_nopush on; #防止网络阻塞
tcp_nodelay on; #防止网络阻塞
keepalive_timeout 120; #长连接超时时间,单位是秒
gzip on; #开启gzip压缩输出

server

虚拟主机

实现一台计算机对外提供多个web服务。

nginx.conf 配置详解_php

其中nginx.conf中的server是默认的server。

server
{
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name localhost;
index index.html index.htm index.php;
root /home/wwwroot/default/;

#error_page 404 /404.html;

# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }


include enable-php.conf;

location /nginx_status
{
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /.well-known {
allow all;
}

location ~ /\.
{
deny all;
}

access_log /home/wwwlogs/access.log;
}