How-to
    How To Add Google AdSense To Your Website
    How To Download Canvas as an image
    How To Embed Youtube Videos
    How To Host NodeJS Apps
    How To Host Static Websites On Amazon AWS EC2
    How To Host Static Websites On Amazon AWS S3
    How To Host Static Websites On GCP Cloud Storage
    How To Install Node.js
    How to Speed Up IntelliJ IDEA / Clion
    How to safely store API Keys

How To Host Static Websites On Amazon AWS EC2

Updated: 2022-02-21

In this tutorial we are deploying a static website to an Ubuntu Server on Amazon AWS EC2. Suppose your host name is test.example.com

On EC2 Instance

Install Apache Server

$ sudo apt-get install apache2

Copy Files

Copy your website files to /var/www/yourwebsite, or make a link:

$ sudo ln -s /home/ubuntu/yourwebsite /var/www/yourwebsite

where /home/ubuntu/yourwebsite is the real location of the website.

Modify Config

$ sudo vim /etc/apache2/sites-available/000-default.conf

Add this to the .conf file

<VirtualHost *:80>
    DocumentRoot /var/www/yourwebsite
    ServerName test.example.com
</VirtualHost>

Restart Server

$ sudo apachectl restart

On AWS Console

Security Groups

Make sure port 80 is open

Elastic IP

Create an Elastic IP xx.xx.xx.xx

DNS

Create an A record and point it ot the ip of the EC2 Instance

NAME    TYPE    DATA
test    A       xx.xx.xx.xx