One of the things we have to do after installing Ubuntu 16.04, and more if we come from a clean installation, is reinstall all those programs that we use in our Ubuntu. If you are a web developer you will surely be interested in installing WordPress on your PC. Therefore, at Ubunlog we want to show you how install WordPress in Ubuntu very easily following only three steps, through a tool called Docker. We tell you.
What is Docker?
First of all and first of all, it is worth explaining what it is and how it works Docker. Well, Docker is a free application that allows us package our software projects in what we know as a container (provided containers, in English). In this way, we can have a Complete file system that contains everything you need (source code, necessary libraries, system tools ...) to be able to run said application on any machine that supports Docker, as if it were a portable app.
Installing Docker and WordPress
Docker has a tool called Docker Compose that precisely helps us to manage the containers of a project, thus being able to start, stop, delete them or see their status. To install it, we just have to execute the following command in the terminal:
sudo apt-get install docker-compose
Using Docker to install WordPress
Now that we know what Docker is and we have it installed, we can proceed to use it to install WordPress.
- The first step is create a directory called, for example, wordpress (I know, it's very original) in the root directory using the following command:
mkdir ~ / wordpress
- Next, inside that directory, we have to create a file called docker-compose.yml, which we can do by going to the created directory and then creating the desired file, that is, executing:
cd wordpress
touch docker-compose.yml
- The file docker-compose.yml has to have the following content:
wordpress:
image: wordpress
Left:
- wordpress_db: mysql
ports:
- 8080: 80
volumes:
- ~ / wordpress / wp_html: / var / www / html
wordpress_db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: examplepass
phpmyadmin:
image: corbinu / docker-phpmyadmin
Left:
- wordpress_db: mysql
ports:
- 8181: 80
environment:
MYSQL_USERNAME:root
MYSQL_ROOT_PASSWORD: examplepass
NOTE: You can manually copy-paste the content of the file or, on the contrary, copy it by executing:
echo file_contents> docker-compose.yml
- The last step is to start Docker, which we can easily do by running:
sudo docker-compose start
Now you just have to open your browser (Firefox, Chromium or Chrome) and go to localhost: 8080 through the upper text box. And that's it! Easy right?
As a final summary, we want to remind you of what we have done. First of all, we have installed docker, a tool that helps us to package a Software project in containers in order to easily port it to any system. Below we have created a file docker-compose.yml with the WordPress configuration required, to finally start Docker. We hope that this post has helped you to install WordPress on your Ubuntu and that, if you have any questions, leave them in the comments section. Until next time
I don't understand one thing. The docker-compose.yml file is a configuration file, but how is wordpress installed?
I continue step by step and it does not work, I have this error when I perform the last command
sudo docker-compose start
ERROR: yaml.scanner.ScannerError: while scanning a simple key
in "./docker-compose.yml", line 4, column 1
could not found expected ':'
in "./docker-compose.yml", line 5, column 1