When you have a PHP-based website like WordPress running on NGINX, you would typically change the maximum file upload size in PHP settings e.g., in php.ini file or similar.

NGINX web server has it’s own configuration where you can set the max upload size server-wide. This is set in the .conf file using the client_max_body_size directive.

To set the maximum upload site server-wide (for all sites on the server)

Find the NGINX config file which is usually located at /etc/nginx/nginx.conf. Open the file and set the directive in the http block.

1
2
3
4
5
6
http {
  #   ...
  client_max_body_size 100M;
  # Sets the maximum file upload size to 100MB.
}

To set the maximum upload site for a particular site running on the server

Find the site’s config file which is usually located at /etc/nginx/sites-enabled/website-name.conf or /etc/nginx/conf.d/website-name.conf. Open the file and set the directive in the server block.

1
2
3
4
server {
  # ...
  client_max_body_size 100M;
}

To set the maximum upload site for a particular folder on the server

You can set this in the site’s config file. Open the .conf file and set the directive in the location block. The folder needs to exist under the website’s folder. In this example, the folder /uploads needs to exist.

1
2
3
4
location /uploads {
  # ...
  client_max_body_size 100M;
}

Restart NGINX

Make sure to restart NGINX after setting any of these options by running

1
2
systemctl restart nginx
service nginx restart