Increase PHP and NGINX upload limits for WordPress
PHP has a 2mb
upload limit. This is often insufficient for some things you want to do with WordPress and may inhibit plugin installation.
To change this, you must make configuration updates to both PHP and NGINX.
This is often a standard task for WordPress sites. However, these instructions also apply to any PHP app where you might need to modify file upload limits.
PHP configurations
In the server > services > PHP settings section (click the wrench icon), you can increase the upload limits, and you will likely want to increase the max_input_time, upload_max_filesize, and memory_limit variables.
Such as:
max_input_time
= 900upload_max_filesize
= 128mmemory_limit
= 256m
NGINX configurations
After updating PHP, go back to the services section and select the wrench icon for NGINX.
- Add
client_max_body_size 128m;
- Save file
- Restart nginx by clicking on the restart icon
This should allow you to upload larger file sizes to your WordPress site. If you are curious whether the configs
were updated and what other configs you might want to alter for your WordPress site. WordPress has a section that displays
current configs located in the WordPress admin dashboard > tools > site health > info > server tab.
wp-admin/admin-ajax.php
502 Errors When Calling Some themes and plugins rely heavily on AJAX requests, which can sometimes cause 502
errors when wp-admin/admin-ajax.php
is called. To attempt to fix this, add the following into the http
section of your /etc/nginx/nginx.conf
.
- Navigate to Server > [The server you want to update] > Services > Nginx.
- Click the three dots on the far right and open the menu.
- Select
Edit nginx.conf
- In the
http
section, add:
##
# FastCGI Settings
##
fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;
- Click
Update
- Click the three dots on the far right to reopen the Nginx menu.
- Select
Restart
.
Once you reload the page generating the error and try again, you should not see the 502
error.