5673 阅读
0 回复
0 点赞
0 收藏
1 #启动进程 2 worker_processes 1; 3 #全局错误日志及PID文件 4 error_log /opt/nginx/logs/error.log crit; 5 6 pid /opt/nginx/logs/nginx.pid; 7 #工作模式及连接数上限 8 events { 9 worker_connections 64; 10 } 11 #设定http服务器,利用它的反向代理功能提供负载均衡支持 12 http { 13 #设定mime类型 14 include /opt/nginx/conf/mime.types; 15 default_type application/octet-stream; 16 #charset gb2312; 17 server_names_hash_bucket_size 128; 18 #设定请求缓冲 19 client_header_buffer_size 32k; 20 large_client_header_buffers 4 32k; 21 22 keepalive_timeout 60; 23 24 fastcgi_connect_timeout 300; 25 fastcgi_send_timeout 300; 26 fastcgi_read_timeout 300; 27 fastcgi_buffer_size 64k; 28 fastcgi_buffers 4 64k; 29 fastcgi_busy_buffers_size 128k; 30 fastcgi_temp_file_write_size 128k; 31 client_body_temp_path /opt/nginx/temp/client_body_temp; 32 proxy_temp_path /opt/nginx/temp/proxy_temp; 33 fastcgi_temp_path /opt/nginx/temp/fastcgi_temp; 34 #开启gzip模块 35 gzip on; 36 gzip_min_length 1k; 37 gzip_buffers 4 16k; 38 gzip_http_version 1.0; 39 gzip_comp_level 2; 40 gzip_types text/plain application/x-javascript text/css application/xml; 41 gzip_vary on; 42 43 client_header_timeout 3m; 44 client_body_timeout 3m; 45 send_timeout 3m; 46 sendfile on; 47 tcp_nopush on; 48 tcp_nodelay on; 49 #设定虚拟主机 50 include /opt/nginx/conf/vhost.conf; 51 }
1 server { 2 listen 80; 3 client_max_body_size 10M; 4 server_name localhost; 5 charset utf-8; 6 index index.html index.htm index.php; 7 #设置D:\wwwroot 为documentroot 8 #root /cygdrive/d/wwwroot; 9 root /opt/www; 10 11 #打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件 12 autoindex on; 13 14 if (-d $request_filename) { 15 rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; 16 } 17 18 error_page 404 /404.html; 19 location = /40x.html { 20 root /opt/www; 21 charset on; 22 } 23 24 # redirect server error pages to the static page /50x.html 25 # 26 error_page 500 502 503 504 /50x.html; 27 location = /50x.html { 28 root /opt/www; 29 charset on; 30 } 31 32 #将客户端的请求转交给fastcgi 33 location ~ .*\.(php|php5)?$ { 34 fastcgi_pass 127.0.0.1:9000; 35 include /opt/nginx/conf/fastcgi_params; 36 } 37 38 #网站的图片较多,更改较少,将它们在浏览器本地缓存15天 39 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 40 { 41 expires 15d; 42 } 43 44 #网站会加载很多JS、CSS,将它们在浏览器本地缓存1天 45 location ~ .*\.(js|css)?$ 46 { 47 expires 1d; 48 } 49 50 location /(WEB-INF)/ { 51 deny all; 52 } 53 54 #设定日志格式 55 log_format access '$remote_addr - $remote_user [$time_local] "$request" ' 56 '$status $body_bytes_sent "$http_referer" ' 57 '"$http_user_agent" $http_x_forwarded_for'; 58 #设定本虚拟主机的访问日志 59 access_log /opt/nginx/logs/access.log access; 60 }
使用道具 举报
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
本文内容不够精彩,我要自己发布
|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )
GMT+8, 2024-12-23 18:25 , Processed in 0.183522 second(s), 22 queries .
Powered by Discuz! X3.5
Cpoyright © 2001-2024 Discuz! Team