file upload exceeds the maximum upload size for this site (LEMP, PHP 7)

I was trying to upload a 3 MB file in a WordPress when I get the error: “file upload exceeds the maximum upload size for this site” in a server with LEMP (Linux Debian, nginx, MySQL, PHP 7, fpm).

To correct this problem, I change the upload_max_filesize in the fpm config file.

Change

upload_max_filesize = 2M

to

upload_max_filesize = 20M

in the /etc/php/7.0/fpm/php.ini file.

Then I restart the service.

# systemctl restart php7.0-fpm.service

Then I have to add the next line

client_max_body_size 20M;

in the nginx config file

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    client_max_body_size 20M;
}

Then I restart the service

# systemctl restart nginx.service

Now I can upload the file.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.