nginx:413 Request Entity Too Large的处理办法--修改 PHP上传文件大小
开发环境:CentOS+Nginx+PHP+MySql+phpMyAdmin
在用phpMyAdmin进行sql数据库导入的时候,经常需要上传比较大的sql数据文件,而这时会常碰见nginx报错:413RequestEntityTooLarge。
解决此问题,根据上传数据文件的大小,你需要调节两个地方的参数配置:
1、php默认上传文件大小限制为2M,如果超出2M你需要修改php配置文件php.ini里面的参数
post_max_size=8M(表单提交的最大限制,此项不是限制上传单个文件的大小,而是针对整个表单提交的数据进行限制。)
upload_max_filesize=2M(上传的单个文件的最大限制)
需要保证post_max_size>=upload_max_filesize,也就是前者不小于后者。
修改之后一定要重启php-fpm。
2.、除了修改php配置,你也需要修改nginx配置文件nginx.conf
打开nginx配置文件nginx.conf,找到http{}段,在其中添加一行配置:
client_max_body_size8m;
其中8m可以根据需要上传文件大小自行设定。
修改之后一定要重新载入nginx(servicenginxreload)。