我已经安装了 bitnami nginx 堆栈(nginx、php-fpm、mysql)来运行多个 drupal 7 和 node.js 站点,但目前只安装了一个 D7 站点。
文件上传在本地主机上完美运行。但是,当我使用 bitnami nginx 堆栈将其上传到 Linode vps 时,它开始显示上传问题。
对于较小的文件(~60kb),上传工作正常。但对于较大的文件,上传会停止。少数情况:563KB 文件 - 上传在 46% 处停止 3.5MB 文件 - 在 ~7% 处停止
POST 的访问日志如下所示(给出 408):
x.x.x.x - - [07/Sep/2014:20:15:24 +0530] "POST /node/add/profile HTTP/1.1" 408 0 "http://mysite[dot]com/node/add/profile" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36"
我尝试了 nginx.conf 文件中所有我能尝试的方法,但没有任何帮助。
user daemon daemon;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access-mysite.com.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
server {
server_name mysite.com;
root /var/www/mysite; ## <-- Your only path reference.
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
sendfile on;
send_timeout 5m;
client_header_timeout 5m;
client_body_timeout 10;
fastcgi_max_temp_file_size 2048m;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# This matters if you use drush prior to 5.x
# After 5.x backups are stored outside the Drupal install.
#location = /backup {
# deny all;
#}
# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}
# No no for private
location ~ ^/sites/.*/private/ {
return 403;
}
# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Subversion or Git to store control files.
location ~ (^|/)\. {
return 403;
}
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
location @rewrite {
# You have 2 options here
# For D7 and above:
# Clean URLs are handled in drupal_environment_initialize().
rewrite ^ /index.php;
# For Drupal 6 and bwlow:
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
#rewrite ^/(.*)$ /index.php?q=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:7777;
}
# Fighting with Styles? This little gem is amazing.
# This is for D6
#location ~ ^/sites/.*/files/imagecache/ {
# This is for D7 and D8
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# client_max_body_size 300M;
}
更新:未使用 Drupal 进行测试,仅使用一个简单的 PHP 脚本 - 同样的故障。肯定与 nginx/php-fpm 有关!
更新 2:关闭 php-fpm 并仅使用带有上传字段的 html 页面进行测试。同样的问题 - 肯定是 nginx 或 bitnami!
答案1
您的 client_max_body_size 超出了服务器定义。将其置于服务器定义内会产生什么结果?
此外,@PratapSingh 还提出了另一个好问题 - php.ini 中的 max_upload_filesize 限制是多少?
尝试这个解释以获得更多帮助。