When we want to develop locally it’s generally handy to have a local version of Wordpress running. This can be done using a Docker container with Nginx and Wordpress out of the box, so you’re good to go in 5 minutes.
Go to https://www.docker.com/get-started/ And install Docker desktop.
Open up a terminal. Make a project folder somewhere in the terminal.
mkdir mywordpress cd mywordpress
Pull in Bitnami’s Wordpress & Nginx container.
docker pull bitnami/wordpress-nginx:latest
After that’s done, make a new file called docker-compose.yml using vim or node.
vim docker-compose.yml
Paste this configuration in the freshly created docker-compose.yml
version: '2' services: mariadb: image: docker.io/bitnami/mariadb:10.6 volumes: - './mariadb_data:/bitnami/mariadb' environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes - MARIADB_USER=bn_wordpress - MARIADB_DATABASE=bitnami_wordpress wordpress: image: docker.io/bitnami/wordpress-nginx:5 ports: - '80:8080' - '443:8443' volumes: - './wordpress_data:/bitnami/wordpress' depends_on: - mariadb environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes - WORDPRESS_DATABASE_HOST=mariadb - WORDPRESS_DATABASE_PORT_NUMBER=3306 - WORDPRESS_DATABASE_USER=bn_wordpress - WORDPRESS_DATABASE_NAME=bitnami_wordpress volumes: mariadb_data: driver: local wordpress_data: driver: local
And save it!
In the same folder where your docker-compose.yml is located, run:
docker-compose up
You successfully set up a Nginx stack with Wordpress installed.
You’re now able to visit your local Wordpress through:
http://localhost:80
https://localhost:443
Go to https://localhost:443/wp-admin
and log in with the following credentials:
As you can see in the docker-compose.yaml file, there’s a folder being made called wordpress_data You can open this folder with your favorite IDE or Text editor and edit files directly.
Have a look at the Bitnami’s docker-wordpress-nginx repo.