How to host your website on EC2 instance & How you can upload and update the bundle using PSFTP?

AWS Services: AWS EC2 instance, AWS Route53.
Other: Putty, PSFTP.

Dhruv Shah
8 min readNov 5, 2020


We all know that nowadays the world is growing quite fast and also technologies are also increasing, even if the individuals are having a small business and wanted to grow fast they must be active in digital marketing, and for that website is a must.

Introduction & Working

The first step for growing your business is to have your website and from this blog, you will be able to learn how to host your website on AWS.

In this blog, we will discuss the following necessary steps to host a website on AWS:

  1. We will create an EC2 instance and will install an apache web server on it.
  2. Then We will learn how to upload your package to the EC2 instance by using putty’s PSFTP.
  3. Finally, we will map our domain with AWS Route53.


Launch an EC2 Instance

  • Open an AWS Management console and under the ‘Services’ pane navigate to ‘EC2’ console.
  • Click on Running instances.
  • Here we can see that no instances are running so click on Launch Instances.
  • Choose the AMI named with Amazon Linux AMI 2018.03.0 (HVM).
  • On this page, you have different options to choose from, choose the one which will satisfy your needs. I’m choosing t2.micro just for the tutorial purpose.
  • Click on ‘Next: Configure Instance’.
  • Here, configure your instance with the below-given details:
    Network: Default VPC.
    Subnet: Choose any one from the list.
    Auto-Assign Public Ip: Enable.
  • Click on ‘Next: Add Storage’.
  • Click on ‘Next: Add Tags’ then again click on ‘Next: Configure Security Group’.
  • In this step, choose ‘Create a new security group’, give the security group name as ‘EC2 SG’, and in description enter ‘EC2 Security Group’.
    Add ‘All ICMP-IPv4’ and source ‘Anywhere’, also set SSH’s source to ‘Anywhere’ and ‘HTTP’ and its source is ‘Anywhere’.
  • Finally, click on ‘Review and Launch’.
  • Click on ‘Launch’.
  • Choose the option ‘Create a New key pair’, give the name as per your wish & then click on ‘Download Key Pair’.
  • Click on ‘Launch Instances’ and again click on ‘Launch’.
  • Scroll down and again click on ‘View Instances’. Your console will look like:
  • Wait for Instance state from ‘Pending’ to ‘available’.

Convert your .PEM file to .PPK file

  • Download Putty and install it on your PC.
  • In the start-menu search for ‘PuTTYgen’ and open it.
  • Click on Load and load the PEM file that you have recently downloaded and click on OK.
  • After uploading the file, click on ‘save private key’.
  • Give the name of that file and click on save.

Phew! We have converted.PEM file into.PPK file.

Taking SSH of our EC2 Instance

  • From the start-menu open PuTTY.
  • Copy the public IP of your EC2 instance from the AWS Management Console and paste it in the HostName of the putty pop-up menu.
    (Select the instance that you recently created and under the details pane you will find your public IP.)
  • Now navigate to Connection > SSH > Auth and click on ‘Browse’. Choose the ppk file that you have downloaded from the previous step.
  • Click on Open and you will be able to take SSH to your EC2 instance and enter ‘ec2-user’ in login as.

(Note: Here hope that you will be able to take SSH to your EC2 instance, if not then kindly comment below I will get out of that problem. Currently not showing the troubleshooting else the blog length will be quite long.)

Updating EC2 instance & Installing and configuring Apache Web Server

  • Enter the below-given commands in the PuTTY SSH console:
    The -y option installs the updates without asking for confirmation.
sudo yum update -y
sudo yum install -y httpd24 php56 php56-mysqlnd
  • If you get the error message No package package-name available, then your instance was not launched with the Amazon Linux AMI. Verify the version of Amazon Linux with the following command.
cat /etc/system-release
  • Start the webserver with the command shown:
sudo service httpd start
  • Configure the webserver to start with each system boot using the chkconfig command.
sudo chkconfig httpd on

Note: To allow ec2-user to manage files in the default root directory for your Apache web server, modify the ownership and permissions of the /var/www directory. In this tutorial, you add a group named www to your EC2 instance. Then you give that group ownership of the /var/www directory and add write permissions for the group. Any members of that group can then add, delete, and modify files for the webserver.

  • Add the www group to your EC2 instance with the following command.
sudo groupadd www
  • Add the ec2-user user to the www group.
sudo usermod -a -G www ec2-user
  • Log out to refresh your permissions and include the new www group.
  • Log back in again and verify that the www the group exists with the groups command.
groups ec2-user wheel www
  • Change the group ownership of the /var/www directory and its contents to the www group.
sudo chgrp -R www /var/www
  • Change the directory permissions of /var/www and its subdirectories to add group write permissions and set the group ID on subdirectories created in the future.
sudo chmod 2775 /var/www 
find /var/www -type d -exec sudo chmod 2775 {} +
  • Recursively change the permissions for files in the /var/www directory and its subdirectories to add group write permissions.
find /var/www -type f -exec sudo chmod 0664 {} +

Uploading files on your EC2 instance

  • We will see how to upload files and folder just by simple steps. I recommend if your bundle contains many folders and sub-folders then save that folder as .zip.
  • Open pageant on your PC. Add the private ppk key to it through which the instance is being launched after adding then close it.
  • Open PSFTP on your local PC.
  • Using basic Linux commands like cd and pwd to redirect and know the current directory respectively. Use the below-shown command to redirect in local PC and your EC2 instance.
    Local PC: lcd, lpwd.
    EC2 Instance: cd, pwd.
  • Use the command given below to transfer the file to your Linux Instance:
    (Note: If your folder is larger in size then wait for some time.)
This image is captured when the file was being uploaded.
  • After the file has been successfully uploaded then open your ongoing PuTTY connection and in that redirect to /var/www/html using command cd /var/www/html and after that by entering command ls you will be able to see the zip file that you have uploaded recently.
  • Unzip this file here by entering the command given below.
  • Delete the zip file by entering the command:
  • Now, go back to your EC2 console and paste your public IP in your browser and hit enter, you will be able to see your website.

Mapping EC2 instance IP with Route53

  • Open AWSRoute53 console.
  • Navigate to Hosted Zones. Click on Create hosted zone.
  • Here in the domain name enter the domain that you have bought.
    (Note: In my case, I’ve bought the domain from GoDaddy)
  • Enter the domain name and then click on Create.
  • Click on ‘Create record’ then add the below-given details:
    Routing Policy: Simple Routing
    Click on Define simple record.
    Record name: www
    Value/Route traffic to IP address or another value depending o the record type (enter the public IP of your EC2 instance in the below-given description box.)
  • So, finally, your dashboard will look like:
  • Copy all 4 your NS record and paste it into GoDaddy’s C-Panel.
  • Open your browser to enter and you can see the webpage.


Thus, with the reference of this blog, you will be able to host your own website on AWS EC2, upload our bundle on an EC2 instance, a map that instance with AWS Route53, and map route53 with the domain name on GoDaddy.

I hope, you like this blog, and if have any doubt then kindly comment below.