For anyone who comes across this issue when running WordPress over docker, the setup is a bit different because we do not have a php.ini file, and here is how you can fix it:
- Exec into your container (running WordPress) and copy the contents of your
.htaccess file with:
docker compose exec wordpress bash
or if you are running the pure docker container:
docker exec -it <container_name/ID> bash
- create the file in your host in the same location from where you are running your docker-compose or you can map the path for more convenience. Add the copied values from your container and include these lines:
post_max_size = 20M
upload_max_filesize = 10M
you should have a final file like this:
# BEGIN WordPress
php_value upload_max_filesize 512M
php_value post_max_size 1024M
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Next, mount this file .htaccess mapping it with the location of the original.
here is my docker-compose example for a production-ready wordpress setup.
services:
wordpress:
image: wordpress:latest
container_name: container_name
ports:
- "8003:80"
environment:
WORDPRESS_DB_HOST: WORDPRESS_DB_HOST:PORT
WORDPRESS_DB_NAME: WORDPRESS_DB_NAME
WORDPRESS_DB_USER: WORDPRESS_DB_USER
WORDPRESS_DB_PASSWORD: WORDPRESS_DB_PASSWORD
WORDPRESS_AUTH_KEY: 'WORDPRESS_AUTH_KEY'
WORDPRESS_SECURE_AUTH_KEY: 'WORDPRESS_SECURE_AUTH_KEY'
WORDPRESS_LOGGED_IN_KEY: 'WORDPRESS_LOGGED_IN_KEY'
WORDPRESS_NONCE_KEY: 'WORDPRESS_NONCE_KEY'
WORDPRESS_AUTH_SALT: 'WORDPRESS_AUTH_SALT'
WORDPRESS_SECURE_AUTH_SALT: 'WORDPRESS_SECURE_AUTH_SALT'
WORDPRESS_LOGGED_IN_SALT: 'WORDPRESS_LOGGED_IN_SALT'
WORDPRESS_NONCE_SALT: 'WORDPRESS_NONCE_SALT'
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DEBUG: 1
WP_HOME: https://WP_HOME.com
volumes:
- wordpress_data:/var/www/html
- ./wp-config.php:/var/www/html/wp-config.php
- /.htaccess:/var/www/html/.htaccess
restart: unless-stopped
volumes:
wordpress_data:
for nginx:
location / {
proxy_pass http://your_host_name:your_port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
client_max_body_size 24000M;
server_tokens off;
}
This should help things out and get you started quickly.
ps aux | grep nginxto see if it is running?which nginx? That will give you the location of the executable, not the config file, but it should at least confirm whether or not nginx is installed.