架构师成长记_第四周_09_Nginx的模块解析及conf配置解析

Nginx模块解析在这里插入图片描述

nginx.conf 配置解释

#user  nobody;    // 默认由 nobody 调用 worker 进程, 可以修改为 root
worker_processes  2;   // 配置 worker进程数


// linux 的日志级别: debug info notice warn error crit 由低到高
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    
    
	// 标准事件模型: select或poll
	// 高效事件模型: Kqueue, Epoll, Eventport
    # 默认使用 epoll
    use epoll;  
    # 每个worker允许连接的客户端最大连接数
    worker_connections  10240;  // 根据硬件配置处理设置
}


http {
    
    
    include       mime.types;   // 导入types文件, include 指令可以引入文件
    default_type  application/octet-stream;  // 默认的type类型


	// 配置日志格式
    #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  logs/access.log  main;   

    sendfile        on;  // 用于文件高效传输
    #tcp_nopush     on;   // 与上面的 sendfile 同时使用

    #keepalive_timeout  0;
    keepalive_timeout  65;  // 客户端连接服务器的超时时间设置, 以秒为单位

    #gzip  on;   // 数据压缩, 可以提高传输效率, 节约服务器带宽, 但是会格外消耗服务器cpu性能

    server {
    
    
        listen       80;  // 设置端口号
        server_name  localhost;  // 设置域名

        location / {
    
       // 设置路由  斜杠为根目录
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
    
    
            root   html;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/Beyond_Nothing/article/details/115276696