zoukankan      html  css  js  c++  java
  • nginx默认配置文件解释

    nginx默认配置文件 nginx.conf 介绍:

    全局配置 user  nginx; 设置nginx服务的系统使用用户
    worker_processes  1; 工作进程数(建议和CPU核心数保持一致)
       
    error_log  /var/log/nginx/error.log warn; 错误日志。 'warn'代表级别
    pid        /var/run/nginx.pid; 服务启动时候的pid
       
       
      events {  
        worker_connections  1024;  每个进程允许最大连接数(一般1W左右可满足大部分企业需求)
    }  
         
         
      http {  
        include       /etc/nginx/mime.types;  
        default_type  application/octet-stream;  
       
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 日志格式,名字为'main',后面的"$XXX"为日志字段
                          '$status $body_bytes_sent "$http_referer" ' $remote_addr:用户IP、$request:请求的方法、$http_referer:referer值
                          '"$http_user_agent" "$http_x_forwarded_for"';  
       
        access_log  /var/log/nginx/access.log  main; 访问日志路径。'main'代表相应log_format名字
       
        sendfile        on; 这个可以提高读取静态文件效率。 开启它之后用户访问静态文件时将直接通过系统内核将文件放入socket,而不是打开文件再将数据放入socket
        #tcp_nopush     on; senffile开启的情况下,提高数据包的传输效率。 即:攒够一定量的包再一起发送,而不是来一个包发一个包
       
        keepalive_timeout  65;  
       
        #gzip  on; 是否支持压缩
       
        include /etc/nginx/conf.d/*.conf;     这句话就将其他配置文件都包含进来了
    }

    nginx默认配置文件 default.conf介绍:

    server { 子server,可以理解为一个server为一台虚拟服务器
        listen       80; 侦听端口
        server_name  localhost; 域名 当一台nginx服务器提供多个域名服务且端口都一样时可以根据用户访问的域名来判断是否应该使用这个server(可以理解为7层的路由),如果用户访问的是app.cctv.com,而这里配的是tv.cctv.com则不会使用该server。
       
        #charset koi8-r;  
        #access_log  /var/log/nginx/host.access.log  main;  
       
        location / { 一个server里面可以有多个location。‘/’代表不管访问主页还是子路径都进入这个location进行访问
            root   /usr/share/nginx/html; ‘root’是存放首页的路径。
            index  index.html index.htm; ‘index’用来指定首页文件,首选index.html,如果没有找到就选index.htm(类似DNS的主备)。
        }  
       
        #error_page  404              /404.html;  
       
        # redirect server error pages to the static page /50x.html  
        #  
        error_page   500 502 503 504  /50x.html; 如果状态码为500 502 503 504则返回/50x.html页面
        location = /50x.html { 定义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$ {  
        #    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;  
        #}  
    }  
  • 相关阅读:
    Problem of saving images in WPF (RenderTargetBitmap)zz
    巴特沃斯(Butterworth)滤波器 (2)
    巴特沃斯(Butterworth)滤波器 (1)
    vs发布的程序不依赖运行时库msvcp100.dll
    [leetcode]Word Search @ Python
    [leetcode]Merge Sorted Array @ Python
    [leetcode]Set Matrix Zeroes @ Python
    [leetcode]Restore IP Addresses @ Python
    [leetcode]Interleaving String @ Python
    [leetcode]Distinct Subsequences @ Python
  • 原文地址:https://www.cnblogs.com/baihualin/p/10896527.html
Copyright © 2011-2022 走看看