发布于 1970-01-01 08:00
  • 6 个回答
    • nginx配置:
      
          keepalive_timeout 600; 
      
          proxy_send_timeout 600;
      
          client_max_body_size 200M;  
      
          fastcgi_connect_timeout 600;
      
          fastcgi_send_timeout 600;
      
          fastcgi_read_timeout 600;
      
          fastcgi_buffer_size 1024k;
      
          fastcgi_buffers 8 1024k;
      
          fastcgi_busy_buffers_size 1024k;
      
          fastcgi_temp_file_write_size 1024k;
      
          proxy_ignore_client_abort on;
      
          tcp_nopush on;
      
          tcp_nodelay on;
      
          client_header_timeout 600; 
      
          client_body_timeout 600; 
      
          sendfile on; 
      
          send_timeout 600;     
      

      php的配置或php-fpm上传大小配置及post大小也需要修改

      根据你的实际情况修改上边的配置吧

      2022-12-01 08:17 回答
    • 具体原因不清楚, 不过502错误一般都是PHP那边出了问题
      不是没响应,就是响应时间过长,等。
      这里已经和nginx没什么关系了

      2022-12-01 08:17 回答
    • 我在Xubuntu 14.04上用测试PHP CLI Server,只配置了下面两条,其他都是默认配置,就能上传90多MB的ZIP包了.

      upload_max_filesize=100M
      post_max_size=128M
      
      php -S 127.0.0.1:8080 -t /png/www/example.com/public_html/
      // chmod 777 /png/www/example.com/public_html/app/yab/static/
      // http://127.0.0.1:8080/app/yab/upload.php
      <?php
      if(!empty($_FILES)){
          $uploaddir = '/png/www/example.com/public_html/app/yab/static/';
          $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
      
          echo '<pre>';
          if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
              echo "File is valid, and was successfully uploaded.\n";
          } else {
              echo "Possible file upload attack!\n";
          }
      
          echo 'Here is some more debugging info:';
          print_r($_FILES);
      
          print "</pre>";
          exit();
      }
      ?>
      
      
      <form enctype="multipart/form-data" action="./upload.php" method="POST">
          Send this file: <input name="userfile" type="file" />
          <input type="submit" value="Send File" />
      </form>
      
      
      

      输出:

      File is valid, and was successfully uploaded.
      Here is some more debugging info:Array
      (
          [userfile] => Array
              (
                  [name] => firefox.zip
                  [type] => application/zip
                  [tmp_name] => /tmp/phpG1PdtU
                  [error] => 0
                  [size] => 93938426
              )
      
      )
      

      同时本地测试了Nginx + PHP-FPM,Nginx只修改了下面这个配置:

      client_max_body_size 128M;
      
      2022-12-01 08:17 回答
    • 经过我测试,上传文件是可以上传成功的,但是我用wget --post-file 就返回502错误
      wget可能有限制大文件上传,
      用curl命令搞定:
      curl -T "msg.log" "http://192.168.1.148/upload.php"
      谢谢大家 结贴!

      2022-12-01 08:17 回答
    • nginx_module_upload

      2022-12-01 08:17 回答
    • 你把php的执行时间调大一点,另外上传超时也调大一点。
      set_time_limit(),max_input_time之类的。你是不是第一次调完后再上传会等一会儿才报502错?

      2022-12-01 08:17 回答
    撰写答案
    今天,你开发时遇到什么问题呢?
    立即提问
    PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有