Edit PHP limit of WordPress container

– make sure the container is running

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
295a2befe1e9 wordpress:latest “docker-entrypoint.s…” About an hour ago Up 32 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp wordpress-site
1ddbd4a5292e mysql:latest “docker-entrypoint.s…” About an hour ago Up 32 minutes 33060/tcp, 0.0.0.0:8889->3306/tcp wordpress_db_1

– ssh into the container

docker exec -it wordpress-site /bin/bash

– This will take you to your /var/www/html as root
– To view your current php limits, run the following ” cat .htaccess ”

# BEGIN WordPress
# The directives (lines) between “BEGIN WordPress” and “END WordPress” are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
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]
</IfModule>

php_value upload_max_filesize 126M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

# END WordPress

– As we cant use or install a text editor, we will use ” sed ”
– To change the values run the following (add your desired value in place of 2G for example 256M):

sed -i “11i php_value upload_max_filesize 2G” .htaccess
sed -i “12i php_value post_max_size 2G” .htaccess

– Verify it has been changed:

cat .htaccess
# BEGIN WordPress
# The directives (lines) between “BEGIN WordPress” and “END WordPress” are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
php_value upload_max_filesize 2G
RewriteCond %{REQUEST_FILENAME} !-d
php_value post_max_size 2G
RewriteRule . /index.php [L]
</IfModule>

php_value upload_max_filesize 2G
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

# END WordPress

– Lastly, you can remove the values using the following command:

sed -i ‘/php_value/d’ .htaccess

No token or token has expired.