PHP與Nginx檔案上傳大小限制如何解決

來源:互聯網
上載者:User
  1. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

  2. #
  3. location ~ \.php$ {
  4. root /home/www/htdocs;
  5. fastcgi_pass 127.0.0.1:9000;
  6. fastcgi_index index.php;
  7. fastcgi_param SCRIPT_FILENAME /home/www/htdocs$fastcgi_script_name;
  8. includefastcgi_params;

  9. client_max_body_size 35m;#用戶端上傳檔案大小設為35M

  10. client_body_temp_path /home/www/nginx_temp;#設定臨時目錄
  11. }

複製代碼

2、修改php.ini在php.ini中查看:

  1. upload_max_filesize = 8M
  2. post_max_size = 10M
  3. memory_limit = 20M
  4. max_execution_time=300
  5. file_uploads = On
複製代碼

預設允許HTTP檔案上傳,此選項不能設定為OFF。upload_tmp_dir =/tmp/www

在上傳大檔案時,會有上傳速度慢的感覺,當超過一定的時間,會報指令碼執行超過30秒的錯誤,修改修改在php.ini設定檔中max_execution_time配置選項,其表示每個指令碼最大允許執行時間(秒),0 表示沒有限制。

可以適當調整max_execution_time的值,不推薦設定為0。

完成以上二處的修改,基本上就可以解決php上傳檔案大小限制的問題了。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.