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;  
    #}  
}  

nginx默认配置文件解释的更多相关文章

  1. Apache之默认配置文件解释

    一.默认配置文件 # 定义apache运行的目录,即程序所在的位置 ServerRoot "/usr/local/apache2" # 定义Apache服务监听的端口 Listen ...

  2. nginx新建nginx_fzjh.conf文件,不使用默认配置文件

    worker_processes 4; events{ worker_connections 1024; } http{ server { listen 80; server_name myserve ...

  3. Nginx安装及配置文件解释

    安装nginx,还是在mac上面用brew比较方便. 首先,brew install nginx,提示改权限 sudo chown -R $(whoami) /usr/local 然后brew ins ...

  4. nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

    一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...

  5. Nginx.conf配置文件默认配置块略解

    #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...

  6. 更换nginx默认端口以及配置文件位置

    前言 近段时间在准备毕业设计的前期准备,基本确定了前后端分离的架构,于是就需要用到了nginx. 在之前nginx是放在docker上,所以没有端口更改跟配置文件配置的烦恼.但是现在是直接放在服务器上 ...

  7. 【nginx运维基础(2)】Nginx的配置文件说明及虚拟主机配置示例

    配置文件说明 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为当前主机的CPU总核心数. worker_processes 8; #全局错误日志定义类型, ...

  8. Nginx的配置文件(nginx.conf)解析和领读官网

    步骤一:vi nginx.conf配置文件,参考本博文的最下面总结,自行去设置 最后nginx.conf内容为 步骤二:每次修改了nginx.conf配置文件后,都要reload下. index.ht ...

  9. nginx详细配置文件 (转)

    Nginx的代码是由一个核心和一系列的模块组成, 核心主要用于提供Web Server的基本功能,以及Web和Mail反向代理的功能:还用于启用网络协议,创建必要的运行时环境以及确保不同的模块之间平滑 ...

随机推荐

  1. SQL Server查询数据库表字段类型

    select b.name,a.name,c.name,a.xprec,a.xscalefrom  syscolumns aleft outer join sysobjects b ON a.id=b ...

  2. vue 借用element-ui实现头像上传 axios发送请求

    <!-- 上传组件 --> <!-- 总结一下: action 写图片上传请求的路径 去路径哈 show-file-list就是当你上传时,是否会显示出上传的是哪一个图片,一般为fa ...

  3. deepin系统右键刷新-解决增删改文件没有变化

    deepin 新建/删除/修改-->文件/文件夹后 目录不刷新解决方案 方法1: F5键刷新 方法2: 通过修改配置文件-->调整最大文件监控数量(建议使用这种方式) sudo vim / ...

  4. acwing 167. 木棒

    乔治拿来一组等长的木棒,将它们随机地砍断,使得每一节木棍的长度都不超过50个长度单位. 然后他又想把这些木棍恢复到为裁截前的状态,但忘记了初始时有多少木棒以及木棒的初始长度. 请你设计一个程序,帮助乔 ...

  5. javaee和javase的区别

    JavaEE是指Java Enterprise Edition,Java企业版,多用于企业级开发,包括web开发等等.也叫J2EE. JavaSE通常是指Java Standard Edition,J ...

  6. 剑指Offer-35.两个链表的第一个公共结点(C++/Java)

    题目: 输入两个链表,找出它们的第一个公共结点. 分析: 先统计两个链表的长度,计算他们的差值,然后将两个链表对齐,再去寻找公共节点即可. 程序: C++ class Solution { publi ...

  7. jenkins传统模式发布istio应用

    一.发布金丝雀版本 Pre Setps cd /var/lib/jenkins/workspace/istio-service-user-canary/istio-service-user # 旧版本 ...

  8. Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick 水题

    B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes ...

  9. 《转》sql处理百万级以上的数据提高查询速度的方法

    处理百万级以上的数据提高查询速度的方法: 1.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描. 2.对查询进行优化,应尽量避免全表扫描,首先应考 ...

  10. 1+x 证书 Web 前端开发初级理论考试(试卷8 )

    Web前端开发初级模拟测试卷(三) 共55道题 总分:200分 形考总分:0分 一.单选题共30题,60分 1.实现向右的红色三角形,样式实现正确的是( ) A <div class=" ...