DEV Community

Mukesh Purohit
Mukesh Purohit

Posted on

How to Launch your Website on AWS using EC2 service...

Step 1:
Create AWS account. (You can create free tier account as well).

Step 2:
We will create EC2 (Elastic Compute Cloud) instance and make it as a web server in order to launch our website.

To launch EC2 Instance in AWS its 7 steps work flow. https://dev.to/its_mukeshp/launch-ec2-instance-in-aws-4f0o

1: Click on “Launch Instance” tab. There will be multiple options for the server you want to purchase, For this example, we will going to select free tier Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type server . Click on Select option and follow the below screenshots in order to launch your instance.

2: Choose an Instance Type
By default it will be on General Purpose (free tier eligible), you can choose others as well but they all are chargeable.

3: Configure Instance Details
Instance with your own VPC (you can think of VPC as a Virtual Data Center on cloud that is unique to you), create your own subnet for the instance, attach the IAM role with your instance etc., but for this example we will going to select default options and click on next.

4: Add Storage
Your instance will be launched with the following storage device settings. You can attach additional EBS volumes and instance store volumes to your instance, or edit the settings of the root volume. You can also attach additional EBS volumes after launching an instance, but not instance store volumes.

5:Add Tags
In Add Storage option, we can adjust our storage based on our needs and choose different types of storage options i.e. General Purpose SSD, Magnetic for our example we are not going to make any change and just click Next to add tags. In Add tags, we will give name to our instance as a key Name and value will be WebServer. Click next for configuring security groups.

6: Configure Security Group
As our EC2 instance will work as a webserver in the next step, Configure Security Group we need to select HTTP protocol by clicking on Add Rule tab on the page and selecting HTTP which will run on port 80, make sure to select source as “Anywhere” instead of default given as “Custom” for both SSH and HTTP. So that you can ssh to your server and manage it remotely.

7: Clicking on Review and Launch, you will just need to verify your configuration and click “Launch” to launch your EC2 instance. Then it will ask you to “create new key pair“ which is basically for your private key file through which you will be able to login to your ec2 instance after verification, then click on “Download Key Pair”. Make sure to save this .pem file in a secure location.

After launching your instance, you should be able to see your instance on your EC2 dashboard.

Step 3:
You can login into your ec2 instance through SSH with the public ip provided by the aws. https://dev.to/its_mukeshp/how-to-ssh-a-linux-instance-using-putty-1cjl

Step 4:
After successfully connected with your EC2 instance (from windows or MAC) in your remote server change sudo to root access and then make your EC2 server as a webserver by typing below commands. Here in this example we are using apache as a webserver (which is httpd in below command).

sudo su
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
service httpd status
cd /var/www/html
nano index.html

In index.html write your html code which you want to display on your website. After that, save your index.html file.

So now, we have successfully configured our EC2 instance. You can validate it by typing your public ip address to your browser.

Top comments (0)