We are going to setup the WordPress site with ubuntu image.
Host setting:–
Prerequisite of host server:–
- Docker must installed.
You can check using below command.
[root@rhel7 ~]# docker –version
Docker version 1.12.6, build 88a4867/1.12.6
Then pull Ubuntu image for a lab setup.
# docker pull ubuntu
Now start two containers with ubuntu image.
- First for web application with port map 82 to 80 and
- second for database with port map 3306 to 3306.
Check docker process are start and running.
[root@rhel7 ~]# docker ps -a
Here you can see port configuration.
0.0.0.0:3306->3306/tcp and 0.0.0.0:82->80/tcp
Now configure web application container.
Login to web application container with below command.
List “CONTAINER ID“
Here we can see “CONTAINER ID” of “ubuntu_apache” is “c92a3e450ca1”.
Now login into the container.
[root@rhel7 ~]# docker exec -it c92a3e450ca1 bash
Now we have prompt look like “root@c92a3e450ca1:/#”.
Next we install all Prerequisite(Apache, PHP, PHP-Mysql) in ubuntu container.
Check apache is accessible on port “82” or not.
root@c92a3e450ca1:/# service apache2 restart
Access URL on the browser.
Now deploy WordPress source code in the container.
Copy WordPress zip file to container.
# docker cp wordpress-4.9.8.tar.gz c92a3e450ca1:/var/www/html/
Then login into container and unzip source code.
Now configure Database container.
Log in to Database container with below command.
List “CONTAINER ID“
Here we can see “CONTAINER ID” of “ubuntu_mysql” is “0b834a2e1484”.
Now login into a container.
[root@rhel7 ~]# docker exec -it 0b834a2e1484 bash
Now we have prompt look like “root@0b834a2e1484:/#”.
Next, we install all Prerequisite(Mysql) in ubuntu container and configure it.
Add this line to access MySql in a network or on IP.
Now start MySql service and configure it.
root@0b834a2e1484:/# service mysql restart
To set root account password and other setting
root@0b834a2e1484:/# mysql_secure_installation
Now login into a database. After that create one database with user access to setup WordPress site.
Here database is “feenix” user is “bnm” and password is “Redhat@12345
Now again restart Mysql service.
root@0b834a2e1484:/# service mysql restart
In a web application container.
Now right time to update database information in WordPress “wp-config-sample.php”.
Make a copy of “wp-config-sample.php” with a name of “wp-config.php”
root@c92a3e450ca1:/# cp wp-config-sample.php wp-config.php
Now access URL on the browser. We have WordPress installation page which indicates web application server successfully communicate with a database server.
After installation, we have a new WordPress website.