nginx的配置文件
首先,我的nginx是源码编译的,版本是官网是提供的稳定版1.12.0、根据的我编译选项,配置文件被我编译到/etc/nginx目录下。
[root@nginxserver log]# nginx -V
nginx version: nginx/1.12.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid
--lock-path=/var/lock/nginx.lock --user=nginx --group=nginx
--with-http_ssl_module --with-http_flv_module --with-http_stub_status_module
--with-http_gzip_static_module --with-pcre --add-module=/opt/rds-json-nginx-module
--add-module=/opt/lua-nginx-module --add-module=/opt/memc-nginx-module
--http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
--http-scgi-temp-path=/var/tmp/nginx/scgi --without-select_module
以上是我学习时编译的nginx参数。(只是学习时用。。。)
配置文件在/etc/nginx目录下,其中的每一个配置文件都提供了备份。
首先/etc/nginx/nginx.conf 是主配置文件。
配置文件一共分为了很多块。
1.全局块
内容: 运行nginx的用户组,允许生成的process数,nginx进程pid的路径,日志的存放路径等等。
2.events 块
内容:nginx服务器与用户的网络连接,worker process 下的网络连接序列化,是否允许同时接受多个网络连接,选取哪种事件驱动模型,每个worker process可以同时支持的最大连接数。
3.http块
内容:文件引入,MIME-Type定义,日志自定义,是否使用sendfile传输文件,连接超时时间,单个连接请求数上限。
4.server块
内容:类似于虚拟主机
5.location块
内容:具体定义页面
下面重点说一下我的nginx的各个块的配置。
全局块:
daemon off;
user nginx nginx;
worker_processes 1;
worker_cpu_affinity 0001;
error_log /var/log/nginx/error.log;
error_log /var/log/ng