zoukankan      html  css  js  c++  java
  • nginx主配置文件详解

    文章来源:《nginx从入门到精通》作者:凉白开,漠北

    nginx主配置文件nginx.conf配置详解:

    vim nginx.conf

    user nobody nobody; #运行nginx的所属组和所有者

    worker-processes 2;   #开启两个nginx工作进程,一般几个CPU核心写几

    error_log logs/error.log  notice; #错误日志路径

    pid logs/nginx.pid; #pid路径

    events {

            worker_connections 1024; #一个进程能同时处理1024个请求

    }

    http {

    include       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  logs/access.log   main;    #默认访问日志路径

    sendfile       on;

    keepalive_timeout 65;       #keepalive超时时间

    #开始配置一个域名,一个server配置段一般对应一个域名

    server {

         listen    80;    在本机所有ip上监听80,也可写为ip:80,这样只会监听ip上的80 端口

        server_name     www.test.com;     #域名

         root    /www/html/www.test.com;    #站点根目录(程序目录)

         index  index.html  index.html;      #索引文件

         location  /  {         #可以设置多个location

                root     /var/html/www.test.com;        #站点根目录(程序目录)

                         }

       error_page     500   502   503  504   /50x.html;           #定义错误页面,如果是500错误,则把站点根目录下的50x.html返回给客户

         location = /50x.html   {

             root            /www/html/www.test.com;

                                         }

    }

    }

  • 相关阅读:
    Luogu-P2295 MICE
    Luogu-P2627 修剪草坪
    Loj-10176-最大连续和
    Luogu-P1886 滑动窗口
    Luogu-P3807 【模板】卢卡斯定理
    Luogu-P1879 [USACO06NOV]玉米田Corn Fields
    Luogu-P1896 [SCOI2005]互不侵犯
    Loj-SGU 223-国王
    Luogu-P2657 [SCOI2009]windy数
    素数
  • 原文地址:https://www.cnblogs.com/xinxiao/p/8260093.html
Copyright © 2011-2022 走看看