To Store the user’s data in AWS database with help of the docker development environment on AWS Ec2-instance
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.
You have need to grant access to the root user and update the system.
Command: sudo su
Command: yum update
Create directory and name is “php-app”. Inside the php-app directory make another directory and name is src.
Inside the src directory make two php files. Copy all the code from github. After create files please come out of the src directory.
Inside the php_site directory make two file. Copy all the code from github.
Oh, docker engine forgot to install. Please install the docker engine and start it.
Command: yum install docker -y
Command: service docker start
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
After check docker compose version, please run docker compose.
Command: docker-compose up
In other terminal, you can check how many containers are created and running position.
Command: docker ps
Copy public ip address of ec2-instance and past any browser and check what happened.
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
In website, fill up the details of the form and check them whether the data is stored in the database or not.
Yeah, Successfully store user’s data in database.
Thank you…!!