nginx 配置文件说明

来源:互联网 发布:淘宝商家会员卡 编辑:程序博客网 时间:2024/06/05 17:04

由于配置文件在etc下

需要sudo 权限

sudo nginx –t 检查配置文件合法

sudo nginx –s reload        重启服务

sudo nginx 启动服务

 

1.      Ubuntu下nginx默认目录在/etc/nginx/nginx.conf

 

2.      核心模块的配置文档参考如下

http://nginx.org/en/docs/http/ngx_http_core_module.html#max_ranges

 

3.  示例

打开上面链接max_ranges 为0的时候表示不支持range-bytes,即不支持http断电续传

max_ranges 0;


nginx.config如下:

user www-data;worker_processes 4;pid /run/nginx.pid;events {worker_connections 768;# multi_accept on;}http {### Basic Settings##sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;server_tokens off;        max_ranges 0;       # server_names_hash_bucket_size 64;# server_name_in_redirect off;include /etc/nginx/mime.types;default_type application/octet-stream;### Logging Settings##access_log /var/log/nginx/access.log;error_log /var/log/nginx/error.log;### Gzip Settings##gzip on;gzip_disable "msie6";# gzip_vary on;# gzip_proxied any;# gzip_comp_level 6;# gzip_buffers 16 8k;# gzip_http_version 1.1;# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;### nginx-naxsi config### Uncomment it if you installed nginx-naxsi###include /etc/nginx/naxsi_core.rules;### nginx-passenger config### Uncomment it if you installed nginx-passenger###passenger_root /usr;#passenger_ruby /usr/bin/ruby;### Virtual Host Configs###include /etc/nginx/conf.d/*.conf;#include /etc/nginx/sites-enabled/*;    #    # The default server    #    server {    listen 80;    server_name nginx-fzy;    root  /home/fzy/www;  #change to www     add_header Accept-Ranges bytes;    #charset koi8-r;    #access_log logs/host.access.log main;    location / {    root /home/fzy/www;    index index.html index.htm index_cn.html index.php index.phtml; #add index.php and index.phtml    # example    #ModSecurityEnabled on;    #ModSecurityConfig /etc/nginx/modsecurity.conf;    }    error_page 404 /404.html;    location = /404.html {    root /home/fzy/www; #change to www     }    # redirect server error pages to the static page /50x.html    #    error_page 500 502 503 504 /50x.html;    location = /50x.html {    root /home/fzy/www;  #change to www     }    # 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 /home/fzy/www;  #change to www     fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME $document_root$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;    #}    }}#mail {## See sample authentication script at:## http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript# ## auth_http localhost/auth.php;## pop3_capabilities "TOP" "USER";## imap_capabilities "IMAP4rev1" "UIDPLUS";# #server {#listen     localhost:110;#protocol   pop3;#proxy      on;#}# #server {#listen     localhost:143;#protocol   imap;#proxy      on;#}#}

原创粉丝点击