To Store the user’s data in AWS database with help of the docker development environment on AWS Ec2-instance

Fenil Vaghasiya
3 min readJul 26, 2022

--

First of fall, You need to launch AWS ec2-instance. Please follow my blog.

Make sure that, allow All tcp port.

After launch ec2-instance, connect ec2-instance via ssh.

Figure: To connect ec2-instance

You have need to grant access to the root user and update the system.

Command: sudo su

Command: yum update

Figure: To update the system

Create directory and name is “php-app”. Inside the php-app directory make another directory and name is src.

Figure: To make directory

Inside the src directory make two php files. Copy all the code from github. After create files please come out of the src directory.

Figure: To create php files in src folder

Inside the php_site directory make two file. Copy all the code from github.

Figure: To create files in php-app folder

Oh, docker engine forgot to install. Please install the docker engine and start it.

Command: yum install docker -y

Command: service docker start

Figure: To install docker engine
Figure: To start the docker engine

Now, install docker-compose. please follow below commands:

Command:sudo curl -L “https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

Command: sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose

Command: sudo chmod +x /usr/bin/docker-compose

Please check docker compose version.

Command: docker-compose -v

Figure: To check version of docker compose

After check docker compose version, please run docker compose.

Command: docker-compose up

Figure: To run the docker compose

In other terminal, you can check how many containers are created and running position.

Command: docker ps

Figure: To see the containers

Copy public ip address of ec2-instance and past any browser and check what happened.

Figure: To past ip in browser

Successfully host our php website.

Now you have go inside the container of mysql_container and inside that container you will need to create database.

Command: docker exec -it <container name> bash

Command: mysql -u root -p

password is helloworld

Figure: To go inside the container
Figure: To create database
Figure: To show entry in table

In website, fill up the details of the form and check them whether the data is stored in the database or not.

Figure: To fill up form
Figure: successfully work website
Figure: To check weather data is store or not

Yeah, Successfully store user’s data in database.

Thank you…!!

--

--

Fenil Vaghasiya
Fenil Vaghasiya

Written by Fenil Vaghasiya

AWS Community Builder | 2x AWS Certified | 1x Azure Certified

No responses yet