Nginx系列-nginx.conf配置文件详解(二)

作者: 温新

分类: 【Nginx】

阅读: 2022

时间: 2021-04-20 16:28:21

简单的记录一下nginx.conf配置文件

#定义Nginx运行的用户和用户组
#user  nobody;

#nginx进程数,建议设置为等于CPU总核心数.
worker_processes  1;

#全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#进程文件保存位置
#pid        logs/nginx.pid;

#工作模式与连接数上限
events {
    #单个进程最大连接数(最大连接数=连接数*进程数)
    worker_connections  1024;
}

# http服务器块
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;
    #tcp_nopush     on;

    #连接超时时间
    #keepalive_timeout  0;
    keepalive_timeout  65;
	
	 #压缩模块   
    #gzip  on;

    #虚拟主机配置
    server {
        #监听端口
        listen       80;
        #监听域名
        server_name  localhost;

        # 编码
        #charset koi8-r;
		  #该虚拟主机请求访问日志存放的位置
        #access_log  logs/host.access.log  main;
	
        #默认请求
        location / {
            #资源文件位置
            root   html;
            #访问文件
            index  index.html index.htm;
        }
	
        #404位置
        #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;
    #    }
    #}

}                       

2021-04-21

请登录后再评论