logo

How To Host Static Websites On Amazon AWS EC2

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