To upgrade the PHP version in a running WordPress app instance, perform the following steps:
First, backup your site data. You can do this by simply connecting to your instance via SSH and copy the directories located in the home directory to a _backup
folder e.g. cp www _backup/
. Once you've backed everything up you can modify the ~/bin/wordpress/Dockerfile
to reflect the updated PHP version. Update the Dockerfile's first line to your desired PHP version:
$ nano bin/wordpress/Dockerfile
Press the ALT + SHIFT + # key combination to show line numbers. Update the first line e.g. FROM php:7.4-apache
to your desired PHP version, for example FROM php:7.4.2-apache
If you are updating from PHP 7.2, there are a couple more updates to make to the file before the image will compile successfully. First, update the following block following LINE 13 of the Dockerfile:
# install the PHP extensions we need...
RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg-dev \
libmagickwand-dev \
libpng-dev \
libzip-dev \ <!-- ADD THIS LINE
; \
Then, update the docker-php-ext-configure
found on LINE 26 command to:
docker-php-ext-configure gd --with-freetype=/usr --with-jpeg=/usr; \
That's all that's needed for the file, the bin/wordpress/Dockerfile
be ready to be built and run. Return to the home directory e.g. cd ~
and run:
$ docker-compose up --build -d
This should now re-run your wordpress container with the newly built image. See our GitHub repo for issues and correct Dockerfile here: https://github.com/aws-appxen/wordpress/blob/master/bin/wordpress/Dockerfile.