码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx 配置文件

时间:2018-08-21 19:45:32      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:级别   session   核心   ase   gen   root   ssl   nginx 配置   gzip   

#user  nobody;

### 工作进程数,可以根据 CPU 核心数量来配置
worker_processes  1;

### 错误日志文件位置
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

### pid 文件,即 nginx 的进程号保存在这个文件里
#pid        logs/nginx.pid;

### 工作模式
events {
    ### 每个进程最大处理连接数
    worker_connections  1024;
}

### http 配置
http {
    ### 支持的媒体类型(html、css、js、pdf...)
    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 函数来输出文件
    sendfile        on;
    #tcp_nopush     on;

    ### 连接超时时间,超过就断开(大文件要特殊处理)
    #keepalive_timeout  0;
    keepalive_timeout  65;

    ### 开启 gzip 压缩
    #gzip  on;

    ### 配置虚拟主机,可以定义多个,一个 server 配置就代表一个虚拟主机
    server {
        ### 监听的端口
        listen       80;
        ### 服务器域名,没有域名就是 IP
        server_name  localhost;

        ### 网页编码
        #charset koi8-r;

        ### 访问该虚拟主机日志位置
        #access_log  logs/host.access.log  main;

        ### 根目录配置
        location / {
            ### 网站根目录配置,这里因为是 nginx 默认的首页就是 html/index.html,以后再开发时要改成项目的根目录
            root   html;
            ### 网站默认访问的页面
            index  index.html index.htm;
        }

        ### 如果程序返回 404 ,返回 404.html 页面
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        ### 如果程序返回 500、502、503、504 就跳转到 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 配置文件

标签:级别   session   核心   ase   gen   root   ssl   nginx 配置   gzip   

原文地址:https://www.cnblogs.com/huanggy/p/9513347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!