user  www www;

pid    /usr/local/nginx/logs/nginx.pid;
error_log /tmp/nginxerror.log crit;
 
worker_rlimit_nofile 65535;
worker_processes  4;
 
events {
worker_connections  51200;
use epoll;
}
 
http {
include       mime.types;
default_type  application/octet-stream;
 
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
client_header_timeout 120;
large_client_header_buffers 4 32k;
client_max_body_size 10m;
client_body_buffer_size  512k; 
 
sendfile on;
tcp_nopush     on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
 
proxy_connect_timeout    600; 
proxy_read_timeout       600; 
proxy_send_timeout       900; 
proxy_buffer_size        4k; 
proxy_buffers            8 32k; 
proxy_busy_buffers_size 64k; 
proxy_temp_file_write_size 64k;
 
gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;
 
#下面两个缓存
  proxy_temp_path /sda1/proxy_temp_dir;
  proxy_cache_path /sda1/proxy_cache_dir levels=1:2 keys_zone=cache_one:256m inactive=1d max_size=3g;
 
#设置后端服务器名称
upstream backend_server {
server   127.0.0.1:80;
}
 
server
  {
    listen   省略IP:80;
        server_name www.bbs;
        root /home/www/public_html/bbs;
index index.php index.html index.htm;
error_page 403 404 500 502 404.shtml;
access_log off;
        if (-d $request_filename) {
                        rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
                        }
 
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
 
if (!-e $request_filename) {
return 404;
}
#设置图片缓存
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|)$
        {
#srcache-nginx-module
#        set $key $uri$args;
#        srcache_fetch GET /memc $key;
#        srcache_store PUT /memc $key;
       proxy_cache cache_one;
       proxy_cache_valid  200 304 1d;
       proxy_cache_valid  301 302 1h;
       proxy_cache_valid  any 30m;
       proxy_cache_key $host$uri$is_args$args;
       proxy_set_header Host  $host;
       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_pass http://backend_server;
       expires 1d;
          }
 
#设置动态页不缓存
    location ~ .*\.(php|cgi)?$
    {
      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
      proxy_pass     http://backend_server;
    }
 
#memc-nginx-module
#        location /memc {
#        internal;
#        memc_connect_timeout 100ms;
#        memc_send_timeout 100ms;
#        memc_read_timeout 100ms;
#        set $memc_key $query_string;
#        set $memc_exptime 300;
#        memc_pass memcache;
# }
       }
 
}
 
以上是我nginx.conf的基本配置,目前状况是,论坛较大的附件无法下载,速度非常慢,从10K会逐步降低到1K左右的速度。lnamp系统构架
 

proxy_cache_dir和proxy_temp_dir 目录都赋予了-R www:www ,设置了777
/usr/local/nginx/proxy_temp这个目录也
赋予了-R www:www ,设置了755

查看了下proxy_cache_dir文件夹下是可以正常生成文件的;proxy_temp_dir文件夹下没有任何东西;/usr/local/nginx/proxy_temp这个文件夹下只有生成的目录,里面没有具体内容。

查看了磁盘io,发现proxy_cache_dir、proxy_temp_dir 、/usr/local/nginx/proxy_temp目录所在的分区写入数据量很多,读取基本为0,求助中

估计是nginx没有传递好路径给apache,

2012/04/21 00:06:16 [error] 20317#0: *1527635 open() 2012/04/21 00:09:11 [error] 20314#0: *1531825 open() "/home/www/public_html/static/image/common/px.png" failed (2: No such file or directory), client: 58.62.55.43, server: www, request: "GET /static/image/common/px.png HTTP/1.1",