禪道上傳文件失敗的解決方法


今天在使用禪道上傳文件的時候發現了一個問題,我可以上傳幾十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,然后進入禪道上傳大文件,哇,成功上傳!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM