Docker Project 2 : CREATING LOCAL WORDPRESS

CREATING LOCAL WORDPRESS AND ITS CONNECTIVITY WITH DATABASE


Introduction to wordpress  : 
WordPress’s rapid growth in popularity over the last few years has not been by accident. For many website developments, there are hardly any other Content Management System’s (CMS) that can match WordPress’ ease of use.
WordPress’ development environment makes it very easy to build a website from scratch and keep it up to date with relevant content. It does not require any web programming language expertise to manage content on a WordPress CMS.

What is WordPress Development?
WordPress powers nearly one-third of the world’s websites, from small personal blogs to the complex sites of major corporations such as Sony, Time Inc., the New York Post, and NBC. WordPress is only one of the site builders and content management systems users can download and install for free, but it has unique features that make it the most popular content management system in use today.
What can WordPress do?
WordPress is an excellent website platform for a variety of websites. From blogging to e-commerce to business and portfolio websites, WordPress is a versatile CMS.
Here are just a few examples of the types of websites you can build with WordPress:
  • Blog
  • E-commerce
  • Business
  • News
  • Photography
  • Music
  • Membership
Benefits of using WordPress Development:-
  • Flexible and Adaptable for Changing Needs
  • User-friendly—Even for Beginners
  • Themes Offer Multiple Options
  • Plugins Extend Functionality
  • WordPress Sites Rank High
  • WordPress Sites Are Mobile Responsive
  • WordPress Sites Have a Built-In Blog
  • The WordPress Community Offers Support

Overview : 

Creating a local framework of wordpress and its connectivity with MySQL database , both are running as containers on DOCKER CE .


I have used the Docker community edition to carry out the desired task and the base OS used here is RED HAT RHEL8 .

Here we go ..

(1)  Pull the MySQL and Wordpress images from the docker HUB :

    #docker pull wordpress
    #docker pull mysql:5.7






1)    To make the DATABASE permanent – use ephemeral storage
-         Create volume
#docker volume create mysql_storage
2)    Run Database server (Container OS) + mouting on permanent folder :
#docker run -dit -e MYSQL_ROOT_PASSWORD=rootpass -e  MYSQL_USER=kshitij -e MYSQL_PASSWORD=redhat -e MYSQL_DATABASE=mydb -v mysql_storage:/var/lib/mysql --name databaseOS mysql:5.7

3)    To make the WORDPRESS data permanent – use ephemeral storage
-         Create volume

#docker volume create wp_storage






4)    Run Wordpress (Container OS) + mouting on permanent folder + port forwarding :

# docker run -dit -e WORDPRESS_DB_HOST=databaseOS -e WORDPRESS_DB_USER=kshitij -e WORDPRESS_DB_PASSWORD=redhat -e WORDPRESS_DB_NAME=mydb -v wp_storage:/var/www/html --name wordpressOS -p 8080:80 --link databaseOS wordpress:5.1.1-php7.3-apache

5)    Install mysql in base RED HAT :
#yum install mysql

6)    Check the IP address of base RHEL 8 :
#ifconfig
<192.168.231.129>

Open in Web browser to verify :








(9)   Login to the new blog : 




1(10)    DashBoard :



1(11)    Creating a new post :










(12)  View my website : 







((13) Verifying the mySQL DATABASE in base RHEL 8 :


# mysql -h 172.17.0.2 -u kshitij -predhat




(14) Getting into the database  :

>Use mydb;




(15)   Show Tables in the database :

>show Tables;



(16)    The Same can be done using Docker Compose (yml file): 


services:
   dbos:
      image: mysql:5.7
      volumes:
           -mysql_storage:/var/lib/mysql
      restart: always
      environment:
         MYSQL_ROOT_PASSWORD: rootpass
         MYSQL_USER: aastha
         MYSQL_PASSWORD: redhat
         MYSQL_DATABASE: mydb
   

   wordpressOS:
      image: wordpress:5.4.0-php1.2-apache
      restart: always
      depends_on:
               - dbos
      ports:
               - 8081:80
      environment:
           WORDPRESS_DB_HOST: dbos
           WORDPRESS_DB_USER: aastha
           WORDPRESS_DB_PASSWORD: redhat
           WORPDRESS_DB_NAME: mydb
      volumes:
           -wordpress_storage:/var/www/html
Volumes :


-wordpress_storage
-mysql_storage




The link for the above docker compose file : 





- KSHITIJ SINGH RATHORE

Comments

Popular posts from this blog

Docker Project 1 : NETWORK AUTOMATION USING DOCKER AND GNS3