Containerized WordPress and MariaDB on AWS EC2

Containerized WordPress and MariaDB on AWS EC2

Summary of Tasks:

  1. Create a virtual machine on AWS

  2. Setup docker and docker-compose on VM

  3. Write a docker-compose file

  4. Execute docker-compose file

  5. Access your web server with VM public IP

  6. Set-up Database

  7. Watch my complete video of this project for troubleshooting

1. Create a virtual machine on AWS

Sign in to your AWS account and click on "Launch instance". Choose Amazon Linux AMI or keep it default

Choose Amazon Linux AMI or keep it default

In the instance type section, choose t2.micro and a key-pair

In the instance type section, choose t2.micro and a key-pair

In the networking section, keep the default settings

In the networking section, keep the default settings

In the storage and advance section, use default settings and click on the "Launch Instance" button on the right top corner

In the storage and advance section, use default settings and click on the "Launch Instance" button on the right top corner

Your virtual machine is ready

Your virtual machine is ready

2. Setup docker and docker-compose on VM

yum install docker -y
service docker start
curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose;

3. Write a docker-compose file

services:
  wordpress:
    container_name: wordpress_web
    image: wordpress
    ports:
      - "80:80"
    volumes:
      - ./efs:/var/www/html
    networks:
      - web_cont_net
    environment:
       WORDPRESS_DB_HOST: mariadb
       WORDPRESS_DB_USER: root
       WORDPRESS_DB_PASSWORD: awais123
       WORDPRESS_DB_NAME: cloud_db

  mariadb:
    container_name: wordpress_db
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: awais123
      MYSQL_DATABASE: cloud_db
    volumes:
      - ./database:/var/lib/mysql
    networks:
      - web_cont_net
networks:
  web_cont_net:

4. Execute docker-compose file

docker-compose up -d

5. Access your web server with VM public IP

you will see such an interface

you will see such an interface

6. Set-up Database

Set-up Database

And your application is ready

And your application is ready

7. Watch my complete video of this project for troubleshooting

If you face any issues, watch my complete video of this project on my channel