HTTP 413報錯

來源:互聯網
上載者:User

標籤:style   blog   http   tar   ext   com   

在php中通過flash上傳檔案到伺服器端時報413錯誤,原來一直以為是php.ini配置的問題,但是檢查了php.ini的配置以後,發現不是php.ini的問題,最後是通過Http Analyzer監控然後發現問題的,在此真的感謝很Http Analyzer。


然後在百度中輸入關鍵字“413 Request Entity Too Large”,發現有一個搜尋結果是與Nginx有關的,正好我們伺服器的環境也是Nginx,按照此文章中的說明對Nginx的配置做了修改,執行/etc/init.d/nginx reload,然後重新進行上傳,不報413錯誤了,鬱悶的問題終於解決了。

以下我是修改配置的情況,就是在location上面添加了一行client_max_body_size 10m;
music1:/data/opt/nginx/conf/vhosts# more ge.mp3cn.net
server
{
        listen       80;
        server_name ge.mp3cn.net;
        index index.php;
        root  /data/www/music/;
        access_log off;

        client_max_body_size 10m;
        location ~* ^.+\.(htm|html|js|css|gif|png|jpg|xml)$
        {
                expires 6h;
                valid_referers none blocked *.mp3cn.net mp3cn.net *.1616.net 1616.net *.1616dh.com 1616dh.com jj.com;
                if ($invalid_referer) {
                        return 403;
                }
        }

        location ~ .*\.php?$
        {
                include fcgi.conf;
                fastcgi_pass  127.0.0.1:9000;
        }

}

php.ini中的有關選項也需要作相應的調整


    ;Maximum size of POST data that PHP will accept.
    post_max_size = 10M
     
    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 10M
     
    max_execution_time = 1800     ; Maximum execution time of each script, in seconds
    max_input_time = 1800    ; Maximum amount of time each script may spend parsing request data
    memory_limit = 128M      ; Maximum amount of memory a script may consume (128MB)

max_execution_time(max_execution_time "30" PHP_INI_ALL)可以用set_time_limit來進行設定,如用set_time_limit(0)表示不逾時。
memory_limit也可以在php程式中進行設定(memory_limit "128M" PHP_INI_ALL)
max_input_time不能在php程式中進行設定(max_input_time "-1" PHP_INI_PERDIR)
php.ini修改完成以後重啟php-fpm,/etc/init.d/php-fpm restart

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.