zoukankan      html  css  js  c++  java
  • nginx 配置文件解析(一)

    nginx.conf

    user              nginx; 
        # nginx服务的运行用户
    worker_processes  1;
        # 启动进程数,通常设置成和CPU的数量相等
    
    error_log  /var/log/nginx/error.log;
        # 错误日志,错误级别
    #error_log  /var/log/nginx/error.log  notice;
    #error_log  /var/log/nginx/error.log  info;
        
    pid        /var/run/nginx.pid;
        # pid文件路径
    
    events {
        worker_connections  1024;
    }
        # 工作模式及连接数上限
            详情见 events详解
    
    
    http {
        # 设定http服务器, 详情见http详解
        include       /etc/nginx/mime.types;
            # 设定 mime类型,类型由mime.type文件定义
        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 指令指定了nginx 是否调用 sendfile函数(zero copy 方式) 来输出文件,
            # 对于普通应用,必须设置为on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的uptime
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
            # 超时时间
        #gzip  on;
            # 启用压缩
        # Load config files from the /etc/nginx/conf.d directory
        # The default server is in conf.d/default.conf
        include /etc/nginx/conf.d/*.conf;
            # 调用其它位置配置文件.
    }

    default.conf

    server {
        # 服务配置项,具体查询server详解
        listen       80 default_server;
            # 监听端口
        server_name  _;
            # 服务名字.
        #charset koi8-r;
            # 字符集
        #access_log  logs/host.access.log  main;
            # 服务自定义的访问日志
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
            # 导入其他位置的配置文件
        location / {
            # 根配置
            root   /usr/share/nginx/html;
                # 根目录的位置
            index  index.html index.htm;
                # 首页直接打开的文件名称从左到右依次搜索
        }
    
        error_page  404              /404.html;
            # 定义错误提示页面
        location = /404.html {
            root   /usr/share/nginx/html;
        }
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
         location ~ .php$ {
            # php 文件的配置,fastcgi配置
             root           html;
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
             include        fastcgi_params;
         }
    
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }
  • 相关阅读:
    Leetcode [654] 最大二叉树 &[105] 从前序与中序遍历序列构造二叉树 & [106] 从中序与后序遍历序列构造二叉树
    Leetcode [226] 翻转二叉树 & [116] 填充每个节点的下一个右侧节点指针 & [114] 二叉树展开为链表
    Leetcode 链表&二叉树刷题总结
    Leetcode 动态规划刷题总结
    Leetcode [1312] 让字符串成为回文串的最少插入次数 动态规划
    Leetcode [234] 回文链表 回文 链表
    动态规划之 KMP 算法详解(转)
    Leetcode [99] 恢复二叉搜索树 二叉树
    统计代码行数
    二叉树遍历(递归、非递归、mirror)转
  • 原文地址:https://www.cnblogs.com/idnf/p/4611208.html
Copyright © 2011-2022 走看看