今天在使用禪道上傳檔案的時候發現了一個問題,我可以上傳幾十k的檔案,但是上傳不了大幾M的檔案,當檔案過大的時候,一直卡在哪裡,上傳不了(使用的是開源版9.8.1)。
在官方文件中可以看到需要調整php.ini 中的 post_max_size 和 upload_max_filesize值,然後重啟apache即可生效:
#cd /opt/zbox/etc/php #vim php.ini ........... register_argc_argv = Off auto_globals_jit = On post_max_size = 50M magic_quotes_gpc = Off magic_quotes_runtime = Off magic_quotes_sybase = Off ............ file_uploads = On upload_tmp_dir = "/opt/zbox/tmp/" upload_max_filesize = 50M allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 ............
進去之後看到我的是50M,說明不是空間的問題,接著從百度看到需要修改my.php中的$config->debug 引數,將false修改為true:
#cd /opt/zbox/app/zentao/config #vim my.php <?php $config->installed = true; $config->debug = true; $config->requestType = 'PATH_INFO'; $config->db->host = '127.0.0.1'; $config->db->port = '3307'; $config->db->name = 'zentao'; $config->db->user = 'root'; $config->db->password = '123456'; $config->db->prefix = 'zt_'; $config->webRoot = getWebRoot(); $config->default->lang = 'zh-cn';
重啟之後再次提交,發現還是上傳不了大檔案,無奈,檢視禪道的日誌,發現裡面有下面這樣的報錯:
16:02:30 ERROR: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) in /opt/zbox/app/zentaobiz/framework/base/router.class.php on line 2145, last called by /opt/zbox/app/zentaobiz/framework/base/router.class.php on line 2103 through function connectByPDO. in /opt/zbox/app/zentaobiz/framework/base/router.class.php on line 2196 when visiting
看日誌似乎是許可權的問題,這時候我就在想如果許可權不對,為什麼小檔案就可以上傳,而大檔案不行,顯然不對,接著在排查,突然想到是不是又是nginx代理的問題,又動手檢視nginx的配置檔案,在配置禪道代理的地方加入一行client_max_body_size 1024M;
#vim nginx.conf
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name xx.xxxx.com; location / { client_max_body_size 1024M; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://192.168.3.175:81; } }
接著重啟nginx,然後進入禪道上傳大檔案,哇,成功上傳!