Introduction
Have you ever thought about creating your own website on WordPress? In this post I will show you how to install WordPress and PhpMyAdmin on Ubuntu 20.04 server using Docker Compose.
Docker Compose allows you to work with multi-container Docker applications by acting as its tool.
It requires Docker to be pre-installed, in our case we will use the pre-installed version of Docker.
You can use the instructions or create a server in Serverspace with Docker already installed.
What's required
- Docker installed on your server, you can install it use to our instructions.
- Server under Linux Ubuntu 20.04 operating system
- 4 Gb of RAM or more
Checking the readiness of the system
First of all, let's check if Docker is running on your server using the command.
systemctl status docker
The parameter "active" has to be "running".
Update the packages on the server.
For future installation, you need to install curl package, you will need it to install Docker Compose.
sudo apt-get install curl -y
Installing Docker Compose
The latest version of Docker Compose is 2.12.2, use the command below to download the repository to your server. You can check the latest version here.
sudo curl -L "https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o /home/docker-compose
Note: The repository will be located at /home/docker-compose.
After installation, the downloaded repository needs to be made executable.
To check, you can use the ls -la command to check the permissions on the folder.
Copy the repository to the system path.
sudo mv /home/docker-compose /usr/local/bin/
Check the installation by running the command docker-compose, it will give you a list of possible commands.
Note: If you get the -bash: /usr/local/bin/docker-compose: No such file or directory error at startup, check that you copied the repository into the system folder. You might get an error -bash: /usr/local/bin/docker-compose: Permission denied, it says that the repository is not executable, give it the rights using the command above.
Installing WordPress and MySQL
Before installing, we have to create the directory and the config for our Docker Compose.
mkdir wordpress
And also create a config.
nano wordpress/docker-compose.yml
In this config, we need to specify the image of wordpress, and the image database MySql, which is needed to run WordPress.
Note: You can change the port to whatever you want.
Run docker to download and check your config.
After launching, it is already possible to go to the web page of our wordpress site, using "https://yourip:8080".
Installing PhpMyAdmin
Before installing it, turn off docker compose.
sudo docker-compose down
To install, you will need to go back to our docker config, and enter the image and network parameters.
To install and verify that it works, run docker.
sudo docker-compose up
After launching, go to the web page using "https://yourip:8081".
The installation is successfully completed.
Conclusion
Docker, allows you to install different packages in just a couple of minutes, thereby saving you time. Thanks to it, you can install any version of a certain package to test your plugins and programs.
Thanks to this publication, you can easily deploy your own site on WordPress, as well as a web interface for the administration of DBMS MySQL - PhpMyAdmin.