Skip to content

Hosting

Matthew Rosenbaum edited this page Nov 4, 2016 · 21 revisions

Sweet Outdoors is hosted through Amazon Web Services. EC2 and Route 53 are the two Amazon Web Services on which our website relies. These Two tools provided us with a Domain Name System and instances of an Ubuntu machine to be a server that could run and render our web application code.

Explanation of the Services

Amazon Elastic Cloud Compute a.k.a. EC2

EC2 is a web service with the primary goal of making cloud computing easier to manage. While this website is fairly narrow in scope and is not expected to have a taxing load of visitors, EC2 provides easy to use, and highly customization, ways to automatically scale and distribute the amount of computing resources used depending on traffic load to the website. The service is not free, but the price scales very nicely for larger application (the price per unit of requests decreases after a certain threshold). The best part about this tool is that it monitors your traffic and responds according to the rules you set. From my experience the service is very easy to use. New instances of servers can be created within 5 minutes. Your instances are controllable via the command line or a very nice and intuitive web GUI.

Amazon Route 53

Route 53 is Amazon's solution to a Domain Name System for web applications. A Domain Name System translates URL strings into IP addresses. Route 53 was an excellent choice of DNS for our web app because R53 is well designed to be able to connect user requests to several different points of an Amazon Web Service structure. In an earlier version of our project we used another Amazon service, S3, to render HTML pages with CSS in a traditional manner - without Python and Flask. Once we decided to integrate Python and Flask into our project we needed to move to using Amazon's EC2 cloud computing service. Route 53 was designed so well that only two drop down boxes need to be changed to make the transition from S3 to EC2. There are many other abilities that support options like Geo DNS and Latency Based Routing.

Amazon RDS

RDS allows us to host a database, in this case our project called for a Postgresql.

Amazon Web Service Identity and Access Management or IAM

IAM essentially allows an account owner to create users with a certain set of permissions. This is useful for shared access among team members, but it is great for allowing secure access to resources for EC2 using applications. Also, its free.

How We Did it

  1. Setting Up Route 53 as your DNS
  • After buying our domain name from the Namecheap registrar, we had to create a Hosted Zone through Route 53. Route 53 generated a set of Name Servers that we provided to Namecheap so that all incoming url requests for sweetoutdoors.me would go to Amazon.
  • Now no matter what Amazon Web Service you choose to use, Route 53 has a simple interface to choose what "endpoint" you want to connect to. Two different server instances via EC2 would be two different endpoints.
  • Updating the DNS across the internet can take up to 48 hours.
  1. Creating An Ubuntu EC2 Instance
  • Using EC2 we created a new instance of an Ubuntu cloud server.
  • EC2 shows the IP address of the server, but provides another option for accessing the instance via an elastic IP which is "attached" to the instance. EC2 does this in such a way that it does not matter what actual IP address our server is using. This is good for being able to stop your instance on one machine and start it on another without having to change what IP a user request is routed to.
  1. Installing Flask, Python, and Apache on our Ubuntu instance
  • Now we have a fresh image of an Ubuntu server, we need to install our web app tools via apt-get and then pip commands like follows:
$ sudo apt-get update  
$ sudo apt-get install apache2  
$ sudo apt-get install libapache2-mod-wsgi  
$ sudo apt-get install python-pip   
$ sudo pip install flask  
  1. Cloning our GitHub Repository
  • We had developed out app locally, now we need to move it over to our instance. To do this we SSH'd into our instance and did the following:
cd /var/www/  
sudo git clone <GitHub repository>
cd <GitHub repository>  
sudo nano app.wsgi 
  • nano is an editor. We placed this in the file:
import sys  
sys.path.insert(0, '/var/www/<GitHub repository>')  
from app import application  
  • then,
sudo nano /etc/apache2/sites-enabled/your_sites.conf  
  • We wrote your_sites.conf to fit our application's needs.
  • These commands enable the site so that the website can be accessed from the URL
sudo a2ensite your_sites  
service apache2 reload  
  1. We created a Postgresql database in Amazon RDS.
  • We simply had to choose Postgres and then change the security groups to allow access to the database.
  • A URL of the form '://:@:/<database_name>' is used to connect to our database with Flask SQLAlchemy.