PHP Configuration

For certain plugins to work and uploading large files in WordPress sites, you may need to change the following setting in php.ini file.

Please use the PHP version folder as per the PHP used or installed by you. In this example, it's version 8.3.

sudo nano /etc/php/8.3/cli/php.ini

Change the following parameters as it suits your installation

memory_limit = 512M
max_execution_time = 900
max_input_time = 900
post_max_size = 256M
upload_max_filesize = 720M

Here are the default config if you want to revert

memory_limit = 128M
max_execution_time = 30
max_input_time = 60
post_max_size = 8M
upload_max_filesize = 2M

In some cases, a plugin upload might be blocked by nginx server. To overcome this, we need to amend the nginx site specific config file

sudo nano /etc/nginx/sites-available/mysite

Add the following line in server block

client_max_body_size 100M;

The config file should look like this

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;


    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

    // This allows larger file uploads upto 100M
    client_max_body_size 100M;
    root /var/www/example;
    index index.php;

Last updated