Increase Upload Limit for WordPress in Docker

Published on — Feb. 21, 2023
#nginx #docker #php #wordpress

You cannot modify php.ini or .htaccess file directly if you choose to deploy WordPress via docker-compose. Here’s a simple solution for you to increase the upload limit. (for LEMP)


Fix “413 Request Entity Too Large”

Modify file nginx.conf:

Add this line to your nginx.conf file:

1
client_max_body_size 100M;

then run

1
$ docker exec -it <nginx-container-name> nginx -s reload

Increase File Upload Size

Create file upload.ini in the same location as your docker-compose.yml file, and fill in:

1
upload_max_filesize = 100M

then modify the docker-compose.yml file:

1
2
3
4
5
wordpress:
  ...
  volumes:
    ...
    - ./upload.ini:/usr/local/etc/php/conf.d/uploads.ini

save and run:

1
$ docker compose up -d --no-deps <wordpress-container-name>

finish.