nginx中相关配置

#nginx 开启目录浏览
    location / {   
        root /data/www/file                  //指定实际目录绝对路径;   
        autoindex on;                        //开启目录浏览功能;   
        autoindex_exact_size off;            //关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;   
        autoindex_localtime on;              //开启以服务器本地时区显示文件修改日期!   
    }

#windows下php-fpm开启多个端口监听
1) 将upstream配置到和server{ }段同一级的的位置。
    upstream fastcgi_backend {
        server 127.0.0.1:9000;
        server 127.0.0.1:9001;
        server 127.0.0.1:9002;
        server 127.0.0.1:9003;
        server 127.0.0.1:9004;
    }

"fastcgi_backend"是配置的这个upstream的名字。

2) 将location中的fastcgi_pass修改成前面配置的upstream。
    location ~ \.php$ {
        root           D:/wnmp/www;
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

#nginx不缓存
expires -1;

#nginx隐藏版本号 [1]
http {
    ...
    server_tokens off;
    ...
}

#php隐藏版本号
在PHP的配置文件php.ini里将expose_php = On改为expose_php = Off


#测试时设置可以允许上传大文件
//php.ini中设置
post_max_size = 80M
upload_max_filesize = 80M
memory_limit = 128M

//设置允许post upload 内容为8M
client_max_body_size 80M;
client_body_buffer_size 80M;

client_header_buffer_size    80M;
large_client_header_buffers  8 80M;

#日志滚动保存
/etc/logrotate.d/nginx

/usr/sbin/logrotate -f /etc/logrotate.d/nginx

posted on 2016-04-10 06:48  dream_bccb  阅读(221)  评论(0)    收藏  举报