Change upload file size in Nginx / PHP-FPM environment

Increase upload max filesizeIt all started on a day when I had to increase the size of a file upload field in Drupal. Changing upload_max_filesize and post_max_size in php.ini wasn’t enough as those needed to be changed in the server’s config as well, Nginx in my case. Below are the steps I took during this small journey:

  1. Increase file size in php.ini
    upload_max_filesize = 400M
    post_max_size = 400M
  2. Increase max body size in /etc/nginx/
    client_max_body_size 400m;
  3. Restart Nginx
    $ service nginx restart

    Now, at this point I could upload bigger files. But it was still showing 64MB in Drupal’s admin. My logic somehow states that Drupal uses php_values to get the server’s file upload size limit set in Nginx. I wasn’t very sure where the php_values had to be set at the server level at first, but finally figured out that /etc/php-fpm.d/www.conf  was the one I wanted to look into.

  4. Add php_values to /etc/php-fpm.d/www.conf
    php_value[upload_max_filesize] = 400M
    php_value[post_max_size] = 400M
  5. Restart php-fpm
    $ service php-fpm restart

And last but not least, refreshing the admin page then showed the correct file size limit. I hope this will save someone some precious time.

Drupal maximum upload size


Sharing is caring!

Leave a Reply

Your email address will not be published. Required fields are marked *