我正在使用 docman 构建一个 Joomla 网站,用于文档管理/下载。该网站建立在运行 Nginx 1.4.2 和 PHP5 (FPM) 的 Ubuntu 14.04 服务器上。
我遇到的问题是文件下载不一致(就大小而言)。例如,我从网站下载了 6 次 PDF 文件,结果如下:
- 72 KB
- 75 KB
- 146 千字节
- 177KB(完整文件)
- 72 KB
- 177KB(完整文件)
本次测试中,6 次中有 2 次成功下载了完整文件。其余 4 次文件不完整。
我的 nginx.conf 如下所示
user www-data;
worker_processes 1;
error_log logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
}
http {
include /etc/nginx/conf/mime.types;
include /etc/nginx/proxy.conf;
include /etc/nginx/fastcgi.conf;
index index.php app.php index.html index.htm;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
keepalive_timeout 0;
#GZIP#
gzip on;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain application/xhtml+xml text/css application/xml application/xml+rss text/javascript application/javascript application/x-javascript
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";
include /etc/nginx/sites-enabled/*;
站点配置如下所示:
server {
listen 80;
server_name example.com;
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
root /www/sites/canmore.link/html;
index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?$args;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_read_timeout 300;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
这是日志文件http://pastebin.com/br0u36xp
2015/11/15 23:51:06 [info] 16075#0: *1 recv() failed (104: Connection reset by peer) while sending to client, client: 24.64.69.223, server: canmore.link, request: "$
2015/11/15 23:51:07 [crit] 16075#0: *3 open() "/var/lib/nginx/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 24.64.69.223, $
2015/11/16 00:24:09 [info] 16228#0: *68 recv() failed (104: Connection reset by peer) while sending to client, client: 24.64.69.223, server: canmore.link, request: $
2015/11/16 00:24:10 [crit] 16228#0: *70 open() "/var/lib/nginx/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 24.64.69.223,$
2015/11/16 00:31:46 [info] 16262#0: *1 recv() failed (104: Connection reset by peer) while sending to client, client: 24.64.69.223, server: canmore.link, request: "$
2015/11/16 00:31:53 [crit] 16262#0: *5 open() "/var/lib/nginx/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 24.64.69.223, $
2015/11/16 00:38:24 [error] 16318#0: *4 open() "/www/sites/canmore.link/html/favicon.ico" failed (2: No such file or directory), client: 24.64.69.223, server: canmo$
2015/11/16 00:38:24 [info] 16318#0: *1 client prematurely closed connection, so upstream connection is closed too while sending request to upstream, client: 24.64.6$
2015/11/16 00:38:51 [info] 16318#0: *17 client 24.64.69.223 closed keepalive connection (104: Connection reset by peer)
2015/11/16 00:38:52 [crit] 16318#0: *14 open() "/var/lib/nginx/fastcgi/3/00/0000000003" failed (13: Permission denied) while reading upstream, client: 24.64.69.223,$
2015/11/16 00:38:55 [crit] 16318#0: *13 open() "/var/lib/nginx/fastcgi/4/00/0000000004" failed (13: Permission denied) while reading upstream, client: 24.64.69.223,$
2015/11/16 00:39:23 [info] 16360#0: *1 recv() failed (104: Connection reset by peer) while sending to client, client: 24.64.69.223, server: canmore.link, request: "$
2015/11/16 00:39:23 [crit] 16360#0: *3 open() "/var/lib/nginx/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 24.64.69.223, $
2015/11/16 00:40:33 [info] 16388#0: *44 recv() failed (104: Connection reset by peer) while sending to client, client: 24.64.69.223, server: canmore.link, request: $
2015/11/16 00:40:34 [crit] 16388#0: *46 open() "/var/lib/nginx/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 24.64.69.223,$
2015/11/16 00:40:44 [crit] 16388#0: *48 open() "/var/lib/nginx/fastcgi/2/00/0000000002" failed (13: Permission denied) while reading upstream, client: 24.64.69.223,$
答案1
根据日志文件解决问题...
我更改了 /var/lib/nginx/fastcgi 文件夹的权限并且它起作用了。
chown -R www-data /var/lib/nginx/fastcgi