Linux architecture of Nginx configuration file

Chapter 42 nginx configuration file

1, Nginx master configuration file

path Types of effect
/etc/nginx/nginx.conf Profiles nginx main configuration file
/etc/nginx/conf.d/default.conf Profiles Default Website Profiles

2, Nginx proxy-related parameter files

path Types of effect
/etc/nginx/fastcgi_params Profiles Fastcgi proxy configuration file
/etc/nginx/scgi_params Profiles scgi proxy configuration file
/etc/nginx/uwsgi_params Profiles uwsgi proxy configuration file

3, Nginx configuration file encoding

path Types of effect
/etc/nginx/win-utf Profiles Nginx encoding conversion mapping file
/etc/nginx/koi-utf Profiles Nginx encoding conversion mapping file
/etc/nginx/koi-win Profiles Nginx encoding conversion mapping file
/etc/nginx/mime.types Profiles Content-Type and extension

4, Nginx management related commands

path Types of effect
/usr/sbin/nginx command Nginx command-line terminal management tool
/usr/sbin/nginx-debug command Nginx with command-line terminal debugging tools

5, Nginx log associated with the file directory

path Types of effect
/ Var / log / nginx table of Contents Nginx default directory to store log
/etc/logrotate.d/nginx Profiles Nginx default log cutting

6, nginx configuration files Comments

Nginx configuration file as a whole is divided into three main learning, namely CoreModule(核心模块), EventModule(事件驱动模块),HttpCoreModule(http内核模块)

 

Main Nginx configuration file /etc/nginx/nginx.conf is a plain text file type, the entire configuration file is organized in the form of blocks. Typically, each block to a pair of braces {} to indicate the beginning and end.

Nginx configuration file as a whole is divided into three main learning, are CoreModule (core module), EventModule (event-driven module), HttpCoreModule (http kernel module)

CoreModule (core module)

user www; #Nginx进程所使用的用户
worker_processes 1; #Nginx运行的work进程数量(建议与CPU数量一致或auto)
error_log /log/nginx/error.log #Nginx错误日志存放路径
pid /var/run/nginx.pid #Nginx服务运行后产生的pid进程号

 

 

EventModule(事件驱动模块)

events {
worker_connections 25535; #每个worker进程支持的最大连接数
use epoll; #事件驱动模型, epoll默认
}

 

HttpCoreModule(http内核模块)

#http层开始
http {
#包含资源类型文件
  include  /etc/nginx/mime.types;
#默认以下载方式传输给浏览器(前提是该资源在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;
#搭配sendfile使用
  #tcp_nopush    on;
#长连接超时时间
  keepalive_timeout    65;
#是否开启压缩
  #gzip    on;

#使用Server配置网站, 每个Server{}代表一个网站(简称虚拟主机)
  'server' {
    listen 80;                 #监听端口, 默认80
    server_name   driverzeng.com;      #提供的域名
    access_log    access.log;         #该网站的访问日志
    #控制网站访问路径
    'location' / {
      root      /usr/share/nginx/html;    #存放网站源代码的位置
      index    index.html   index.htm;    #默认返回网站的文件
    }
  }
  ...
  #第二个虚拟主机配置
    'server' {
  ...
  }

  include  /etc/nginx/conf.d/*.conf;      #包含/etc/nginx/conf.d/目录下所有以.conf结尾的文件
} #http结束层

 

 

Guess you like

Origin www.cnblogs.com/dabai-wang09/p/11355488.html