写php简单上传图片时,发现200k的图片上传时报Internal Server Error错误,检查了upload_max_filesize,及其他post_max_size、max_input_time、memory_limit、max_execution_time配置项均没有问题,后检查错误日志:mod_fcgid: HTTP request length 138296 (so far) exceeds MaxRequestLen (131072),发现问题所在。
原 来是fastcgi模式下的设置问题,看上去是因为HTTP刚才的请求长度(138296 )太长,大于现有的131072最大请求长度。看了fcgid 的配置文件后,发现并没有配置过MaxRequestLen的参数。看来这个131072的配置是默认的了。于是在fcgid的配置文件里加入这个配 置,15728640是15M,因为我的php.ini中设置的最大POST长度是15M,所以把它们设置长一样 的:MaxRequestLen 15728640;
<IfModule mod_fcgid.c> MaxRequestLen 15728640 AddHandler fcgid-script .fcgi .php # Where to look for the php.ini file? FcgidInitialEnv PHPRC "e:/wamp/bin/apache/apache2.3.14/bin" # Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess # to prevent php-cgi process from exiting before all requests completed FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000 # Maximum requests a process should handle before it is terminated FcgidMaxRequestsPerProcess 1000 # Maximum number of PHP processes FcgidMaxProcesses 15 # Number of seconds of idle time before a php-cgi process is terminated FcgidIOTimeout 120 FcgidIdleTimeout 120 #Path to php-cgi FcgidWrapper "e:/wamp/bin/php/php5.4/php-cgi.exe" .php # Define the MIME-Type for ".php" files AddType application/x-httpd-php .php </IfModule>
里面的“MaxRequestLen”就是fastcgi模式下上传文件也就是http接受的最大文件长度。
问题解决
注:
PHP默认的上传限定是最大2M,想上传超过此设定的文件,需要调整PHP、apache等的一些参数。下面,我们简要介绍一下PHP文件上传涉及到的一些参数:
对于linux主机,可能在/etc/httpd/conf.d/access.conf/下面里面还有php.conf 文件,这个文件可能会解决一些系统的文件大小限制问题。
php 图片上传 500 Internal Server Error 错误,布布扣,bubuko.com
php 图片上传 500 Internal Server Error 错误
原文:http://www.cnblogs.com/phpdragon/p/3675363.html