HTTP 413报错

在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

转载于:https://www.cnblogs.com/myphper/p/3808710.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值