美文网首页
Nginx配置文件详解

Nginx配置文件详解

作者: M醉逍遥 | 来源:发表于2017-03-25 10:20 被阅读0次
    # 配置可启动nginx的用户
    #user  user [group];
    #不限制用户则可注释user行,或像如下配置:
    #user nobody nobody;
    #user  nobody;
    
    #配置nginx工作进程数,一般与cpu核数相同
    #worker_processes  number | auto;
    worker_processes  1;
    
    #配置错误日志存放路径及错误日志输出级别(debug,info,notice,warn,error,crit,alert,emerg)
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #配置pid存放路径
    #pid        logs/nginx.pid;
    
    #引入其他配置文件,file支持相对路径
    #include file;
    
    events {
        #开启nginx进程接收链接序列化,防止多个进程对连接的争抢。默认为on。只能配置在events中
        #accept_mutex on | off;
        #配置是否开启每个work process同时接收多个新到达的网络连接,默认为off。只能配置在events中
        #multi_accept on | off;
        #配置强制使用某种事件驱动模型来处理网络消息。method包括:select,poll,kqueue,epoll,rtsig,/dev/poll,eventport。只能配置在events中
        #use method;
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #服务日志可是定义,只能在http块中配置
        #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()传输文件
        sendfile        on;
        #配置每个work process每次调用sendfile()传输的数据量最大值;若为0则不限制
        #sendfile_max_chunk size;
        #tcp_nopush     on;
    
        #配置nginx与用户建立连接会话后,nginx保持这个连接打开的一段时间(单位s)
        #keepalive_timeout  timeout[ header_timeout];
        keepalive_timeout  65;
        #该指令用于限制用户通过某一连接向nginx服务器发送请求的次数
        #keepalive_requests number;
    
        #gzip  on;
    
        server {
            #设置监听IP与端口
            #监听所有IP的80和8000端口
            #listen *:80 | *:8000;
            listen       80;
            #配置虚拟主机名称
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   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;
            #}
        }
    
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        #
        #server {
        #    listen       443 ssl;
        #    server_name  localhost;
    
        #    ssl_certificate      cert.pem;
        #    ssl_certificate_key  cert.key;
    
        #    ssl_session_cache    shared:SSL:1m;
        #    ssl_session_timeout  5m;
    
        #    ssl_ciphers  HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    }
    
    
    

    相关文章

      网友评论

          本文标题:Nginx配置文件详解

          本文链接:https://www.haomeiwen.com/subject/qvxlnttx.html