Going with this blog you are supposed to have basic knowledge of Ubuntu commmands, EC2 instance, VPC security group, Route 53, and a domain whom we are hosting on AWS (Here we will use example.com for reference). Lets start hosting a website on EC2 Ubuntu (64bit) machine.
After launching instance, login to this instance with SSH access. After successful login we need to upgrade all packages that the Ubuntu OS installed at the time of setting up an EC2 instance.
# Upgrade your OS packages to latest one
sudo apt-get update && sudo apt-get upgrade
Step 2 :
Install server to host website on this instance. We are going to install Apache web server for this process.
# Download and install apache on Ec2 instance
sudo apt-get install apache2 apache2-doc apache2-utils
# Enable multipurpose module
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
(Ref : https://www.linode.com/docs/web-servers/apache/apache-web-server-on-ubuntu-14-04 )
# We need to restart Apache server, us following command to restart web server
sudo service apache2 restart
Now apache server installed. We have to setup an example.com . For this we need to create a virtual host on this apache server. The path for the config file of Virtual server is /etc/apache2/sites-available/
Here are two methods to create virtual host
- Creating virtual host in a separate file other than 000-default.conf
- Creating virtual host in 000-default.conf
Step 4 (create directory for example.com domain) :
#Create Directories for website
sudo mkdir -p /var/www/example.com/public_html
sudo mkdir /var/www/example.com/logs
# Content or files in var/www/example.com/public_html/ directory will be root directory for public
Create index file for your domain example.com
#You can create index.html for example.com
sudo nano index.html
#Nano editor will open, write your code in index.html file and save
Step 5 (Configure Route 53 for example.com ):
AWS panel go to Create Hosted Zone in Route 53
After creating hosted zone for example.com you will get at least 4 DNS (nameservers) from amazon for the domain.
You need to update these nameservers in your domain registrar (as: Godaddy, Hostgator, BigRock etc) panel.