DEV Community

Cover image for How to build and Deploy an E-Commerce Platform with Git-Linux-and-AWS
Oluwatobi
Oluwatobi

Posted on

How to build and Deploy an E-Commerce Platform with Git-Linux-and-AWS

Project Description:

To develop an e-commerce website for a new online marketplace name "Agate Interior". This platform will feature product listings, a shopping cart, and user authentication.

Task:

  1. To utilize Git for version control, develop the platform in a Linux environment, and deploy it on an AWS EC2 instance.
  2. Continous integration and development workflow
  3. Developing New features and fixes
  4. Version Control with Git
  5. Pull Requests and Merging to ain branch
  6. Deploying Updates to the Production Server
  7. Testing the new changes

Step 1:

Initialize Git Repository

  • Create a new Repository

1_aws

  • Copy SSH/HTTP (depending on the one you use best)

2_aws

  • Clone the Repo
    git clone "Paste the URL"

  • Confirm it has been successfully downloaded into your local Repo

3_aws

## Step 2:

Obtain and Prepare the E-Commerce Website Template

Instead of developing the website from scratch, use a pre-existing e-commerce website template

4_aws

  • Extract the Downloaded template into your project Directory that you've created

  • Customize the template if you have a basic web development skill. (I Tailored mine to Agate Interior)

5_aws

## Step 3:

Stage and Commit the Template to Git

  • Run ls to confirm the directory
  • git add "Directory_name" to stage the codes

6_aws

  • Run git status to see if it's successfully staged

7_aws

  • Run git commit -m "your message" to commit your code

8_aws

  • git push / git push -u origin main to push your code to your remote Repo

9_aws

  • Go to your Github to confirm the changes

10_aws

## Step 4:

AWS Deployment

To deploy, you'll start by setting up an Amazon EC2 instance

  • Log in to the AWS Management Console

11_aws

  • Launch An EC2 Instance Using an Amazon Linux AMI

  • Remember to download a key pair

12_aws

13_aws

  • Connect to the to your local Repo using SSH
  • Copy the URL

14_aws

You have successfully launched an EC2

## Step 5:

Connect and Clone the repository on the Linux Server

You need to clone the GitHub repository to your AWS EC2 instance. This process involves authenticating with GitHub using SSH

  • Open your Local Server
  • Paste the URL copied from your EC2 to connect your local server to the remote server

15_aws

  • Run ssh-keygen to generate an SSH keypair

  • Press enter to use the default file directory and passphrase

17_aws

  • Run cat /home/ec2-user/.ssh/id_rsa.pub (copy the content)

18_aws

  • Navigate to your Repository in GitHub Console, click on settings

19_aws

  • Navigate to SSH and GPG key, create a new SSH key

21_aws

  • Paste the Copied content, and add the SSH key

22_aws

Install git on your EC2 server if you have it installed

To check if it is installed or not

  • Run which git

23_aws

  • To install, run sudo yum install git

24_aws

Clone the Repository

  • Navigate back to Repo and copy the SSH URL

16_aws

  • Clone Repo

25_aws

## Step 6:

Install a Web Server on EC2

Apache HTTP Scerver

Installing it on Linux EC2 server allows you to host "Agate Interior"

  • Install the Apache web server on the EC2 instance.
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

26_aws

  • Configure httpd for the website
sudo rm -rf /var/www/html/*
sudo cp -r ~Agate_interior/* /var/www/html/
Enter fullscreen mode Exit fullscreen mode

27_aws

  • Reload httpd

sudo systemctl reload httpd

28_aws

Step 7:

Success Website from browser

  • Open a web browser and access the public IP of your EC2 instance to view the deployed website

29_aws

## Step 8:

Continuous Integration and Deployment Workflow

  • Developing New Features and fixes

  • git checkout -b Development to create a new branch

30_aws

  • Make your New development

31_aws

  • Stage your Edit
git add "index.html"
git commit -m "your message"
git push
Enter fullscreen mode Exit fullscreen mode

32_aws

  • Go to your GitHub

33_aws

34_aws

35_aws

  • Git pull

36_aws

Step 8:

Deploying Updates to the Production Server

  • Pull the latest changes on the Server

37_aws

  • Follow and study the code

38_aws

  • Code Updated

Before

5_aws

After

39_aws

Top comments (0)