WordPress

Fix Error: Exceeds the maximum upload size for website (NGINX Server)

If you are trying to upload a file to your WordPress site and you receive the error message “exceeds the maximum upload size for this site,” here is a way to fix the issue on Nginx server.

  1. Connect to your WordPress site using an FTP client or the Azure App Service Editor.
  2. Navigate to the root directory of your WordPress site.
  3. Create a new file named .user.ini. Note that the file name starts with a dot (.) to indicate that it is a hidden file
  4. Open the .user.ini file in a text editor.
  5. Add the following code to the file
    upload_max_filesize = 64M
    post_max_size = 64M

    Note: In this example, the upload_max_filesize and post_max_sizevalues are set to 64 MB. You can adjust these values to meet your needs.

    You can also increase the post_max_size,max_execution_time, and max_input_time values by adding them to the .user.ini file. These settings are typically used to adjust the maximum file size, maximum script execution time, and maximum input processing time, respectively.

    post_max_size=64M
    max_execution_time=300
    max_input_time=300
  6. Save the changes to the .user.ini file.
  7. Restart your Azure App Service to apply the changes.
  8. To ensure successful file uploads, you also need to update the ‘client_max_body_size’ limit in the Nginx server configuration file. client_max_body_sizeis a configuration directive in the Nginx server that sets the maximum allowed size of a client request body. It is used to prevent clients from sending excessively large requests that could consume server resources and cause other issues.By default, the client_max_body_size directive is set to 1 megabyte (1MB) in Nginx. This means that if a client tries to upload a file larger than 1MB, Nginx will reject the request and return a “413 Request Entity Too Large” error.To increase the client_max_body_size limit in Nginx, you can add the following line to the server block in the Nginx configuration file:client_max_body_size 64M;
    server {
    	...
    	...
    	...
    	client_max_body_size 64M;
    }
    

    Note
    You can copy the existing Nginx configuration file using SSH by running the command cp /etc/nginx/sites-available/default /home/site/ in your SSH terminal. This will create a copy of the default Nginx configuration file in the /home/site/ directory.

    Once you have copied the file, you can modify it using a text editor of your choice.

Views: 45

Standard