DEV Community

Zerah Abba
Zerah Abba

Posted on

Deploying Website on AWS EC2 server

Prerequisites

  1. AWS account. (https://youtu.be/SFaSB6vgp8k)
  2. Internet connection.
  3. pUTTY for windows (https://apps.microsoft.com/detail/xpfnzksklbp7rj?hl=en-US&gl=US)

Implementation Steps

  1. Setting up instances on AWS.
  2. Connecting to AWS instance.
  3. Configuring instances for Web Hosting.
  4. Hosting

1.) Setting up instance on AWS.

These are the steps needed to create an ec2 instance.

  • Login to console
  • Launch and Configure instance.
  • Start instance.

Log into console:

You log into the console by going into the browser and accessing the AWS amazon cloud. Then log in your account details. Your console shouid look like the below image.

login

Launch instance and configure:

To successfully configure and launch your instance you would need to create an instance. To do this, navigate to the create button. You can complete the configuration process by:

  • Selecting the instance type.

instance

  • Setting rules.
    rules

  • Choosing key-pairs.

keypairs

  • Configure AMI.

AMI

  • Finally, launch the instance.

launch

2.) Connecting to AWS instance.

The following are steps to connecting to instance using puTTY.

  • Open puTTy generator and convert .pem key extension to .ppk. This is for experimental purpose to show that .pem could be used. You could just directly use .ppk.
  • Use puTTY to acess ec2 instance.

Open puTTY generator.

  • Click on your puTTY generator.
  • Choose load and select key pair to be converted to .ppk

.ppk

Use puTTy to access ec2 instance

  • Open puTTY and add ec2 instance public key.

public

ip

  • Add the private keys by going to SSH > Credentials tab.

private

  • Accept the conditions after clicking the load button.

Accept

ec2

3.) Configuring instance for Web Hosting.

This is to make the instance able to deploy a website. Here are the steps to follow.

  • Update server
  • Become the sudo user.(optional)
  • Make working directory.
  • Download files into directory.
  • Unzip files.
  • Move them into the var/www/html folder.
  • Install httpd
  • Enable, start and check status.

Update Server

  • Update server using the command "sudo yum update -y"
sudo yum update -y
Enter fullscreen mode Exit fullscreen mode
  • Become sudo user using command.
sudo su
Enter fullscreen mode Exit fullscreen mode
  • Make working directory with any name.
mkdir tmp
Enter fullscreen mode Exit fullscreen mode
  • Download files into working directory by using the wget command.In this case we can use a free css template.
wget "link"
Enter fullscreen mode Exit fullscreen mode

download

  • Unzip the zip files with "unzip"
unzip "filename"
Enter fullscreen mode Exit fullscreen mode
  • Move files to var/www/html. Using the mv command.

boxer

  • Install httpd.

httpd

  • Enable, start and check httpd using the systemctl command.
systemctl enable httpd
systemctl start httpd
systemctl status httpd


Enter fullscreen mode Exit fullscreen mode

Hosting

To host, you would have to copy the ip address of the ec2 instance and paste to your browser. The result below should be an example of what should be shown.

boxer

Conclusion

The EC2 instance is used to successfully deploy the object in the S3 bucket. This is possible with the aid of roles. This role gives the instance the permission to allow S3 bucket authorization.

Top comments (0)