nginx - client_max_body_size has no effect

前端 未结 13 1884
无人共我
无人共我 2020-11-28 01:13

nginx keeps saying client intended to send too large body. Googling and RTM pointed me to client_max_body_size. I set it to 200m in th

13条回答
  •  一个人的身影
    2020-11-28 01:27

    You need to apply following changes:

    1. Update php.ini (Find right ini file from phpinfo();) and increase post_max_size and upload_max_filesize to size you want:

      sed -i "s/post_max_size =.*/post_max_size = 200M/g" /etc/php5/fpm/php.ini
      sed -i "s/upload_max_filesize =.*/upload_max_filesize = 200M/g" /etc/php5/fpm/php.ini```
      
    2. Update NginX settings for your website and add client_max_body_size value in your location, http, or server context.

      location / {
          client_max_body_size 200m;
          ...
      }
      
    3. Restart NginX and PHP-FPM:

      service nginx restart
      service php5-fpm restart
      

    NOTE: Sometime (In my case almost every time) you need to kill php-fpm process if it didn't refresh by service command properly. To do that you can get list of processes (ps -elf | grep php-fpm) and kill one by one (kill -9 12345) or use following command to do it for you:

    ps -elf | grep php-fpm | grep -v grep | awk '{ print $4 }' | xargs kill -9
    

提交回复
热议问题