【備忘】[轉載]php Apache 上傳大文件報錯(Internal Server Error)問題解決方案

[轉載]

在百度中噼裏啪啦進行一番搜索,查閱資料,有個哥們已經寫了一篇文章,能解決我的問題。但是我還是要記錄一下,增強記憶。

原文參考:https://blog.csdn.net/Jokenzhang/article/details/105675061

我的這個問題的現象:

場景:我已經做了一個上傳文件的功能,一般情況下都是沒有問題的,突然有一天測試妹紙說,上傳文件失敗了。經過分析,定位的原因是文件太大,導致失敗。

當我知道是這個問題的時候,第一反應就是修改PHP.ini上傳文件的限制相關設置。

一頓操作之後,重啓apache之後,還是一樣的效果:

報錯:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

這個問題在早之前都遇到過,只是當時用其它方式避免了。可是,久走夜路要闖鬼,今天還是要直面這個問題。

so!我決定搞定它!

參考上面原文:

修改了php.ini上傳相關配置:

max_execution_time = 600 ;每個PHP頁面運行的最大時間值(秒),默認30秒
max_input_time = 600 ;每個PHP頁面接收數據所需的最大時間,默認60秒
memory_limit = 8m ;每個PHP頁面所喫掉的最大內存,默認8M
把上述參數修改後,在網絡所允許的正常情況下,就可以上傳大體積文件了
file_uploads = on ;這個很重要,必須要on纔可以
upload_max_filesize = 32m ;根據需求改到最大
post_max_size = 32m ;表單提交的最大尺寸
file_uploads = On 這裏設置是否允許HTTP上傳,默認應該爲ON的 
upload_tmp_dir= 這裏設置上傳文件存放的臨時位置,必須指定

再修改Apache的配置:

<IfModule mod_fcgid.c>
        AddHandler    fcgid-script .fcgi
        #
        FcgidConnectTimeout  20
        # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
        MaxRequestLen  157286400000
</IfModule>

重啓之後就解決了我上傳文件過大的問題!感謝小夥伴的文章!

 

END

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章