【问题标题】:Error uploading large files using PHP 5.6 & Apache 2.4使用 PHP 5.6 和 Apache 2.4 上传大文件时出错
【发布时间】:2016-04-19 20:27:21
【问题描述】:

我已经在我的 Windows 开发工作站上解决了这个问题三天了。我已经研究了很多,并在 Apache 的 httpd.conf 和 PHP 的 php.ini 中更改了很多设置,并且没有取得任何明显的进展。问题是我能够上传最大 100KB 的图像文件,但是在 100KB 到 300KB 之间的某个地方我开始出现超时。我希望能够上传最大 1MB 的图片。

在超时之前的某个时间点,我在 PHP 代码上设置了一个断点,所有 $_POST 变量都是空的。

总结:

  • 最多 100K -> 上传成功,我在输出中看到“是”
  • 介于 100K 和 ~300K 之间 -> 我能够执行 PHP 代码,但所有 $_POST 变量都是空的
  • 超过 ~300K -> 超时

这是代码:

<?php

   if( $_SERVER["REQUEST_METHOD"] == "POST" )
   {
      if( $_FILES["fileToUpload"]["error"] == UPLOAD_ERR_OK )
      {
         echo "Yes";
      }
   }
?>
<!DOCTYPE html>
<html>
<body>

<form action="TestFileUpload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="fileToUpload" id="fileToUpload">
    <br />
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

这是相关的httpd.conf

LimitRequestBody 20000000

这是相关的php.ini

max_execution_time = 1800
max_input_time = -1
post_max_size = 100M
upload_max_filesize = 100M
memory_limit = 1024M

这是 Apache 的 access.log

127.0.0.1 - - [14/Jan/2016:11:01:39 -0200] "GET /TestFileUpload.php HTTP/1.1" 200 280
127.0.0.1 - - [14/Jan/2016:11:02:10 -0200] "POST /TestFileUpload.php HTTP/1.1" 408 221

这是 Apache 的 error.log(我清除了它并重新启动服务器以获得干净的输出)

[Thu Jan 14 10:57:00.709518 2016] [ssl:warn] [pid 4972:tid 448] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jan 14 10:57:00.738518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00455: Apache/2.4.6 (Win32) OpenSSL/1.0.1e PHP/5.5.5 configured -- resuming normal operations
[Thu Jan 14 10:57:00.739518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00456: Apache Lounge VC11 Server built: Jul 15 2013 20:13:45
[Thu Jan 14 10:57:00.739518 2016] [core:notice] [pid 4972:tid 448] AH00094: Command line: 'C:\\Program Files\\Apache Software Foundation\\Apache24\\bin\\httpd.exe -d C:/Program Files/Apache Software Foundation/Apache24'
[Thu Jan 14 10:57:00.753518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00418: Parent: Created child process 1952
[Thu Jan 14 10:57:02.548518 2016] [ssl:warn] [pid 1952:tid 396] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jan 14 10:57:02.575518 2016] [mpm_winnt:notice] [pid 1952:tid 396] AH00354: Child: Starting 64 worker threads.

我没有在 Apache 中使用 mod_security。

任何想法我还能尝试什么,任何配置?

【问题讨论】:

标签: php apache


【解决方案1】:

您是否查看过 httpd 配置文件的 fcgid 部分中的超时设置?

<IfModule mod_fcgid.c>
[settings]
</IfModule>

可能是 FcgidBusyTimeout 设置。默认值为 100;并增加这可能会帮助你。试试:

<IfModule mod_fcgid.c>
FcgidBusyTimeout 9999
</IfModule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-14
    • 2017-09-30
    • 2012-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-31
    • 1970-01-01
    相关资源
    最近更新 更多