【备忘】[转载]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

 

 

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