How to Set Up an Amazon Web Server for Cheap

By Raising Awesome © August 1, 2021


Introduction

So, you may already built a .Net web site on a Raspberry Pi. However, leaving that port open 24/7 makes you a little nervous. I've never had an issue with it, but I, too, still felt better landing my site on a free AWS server. So, we moved ours there. This blog will show you how to do it for a price of about $2 bucks for the first year.

Good reasons to do it: What to expect: Don't feel intimidated by this. You definitely can do this. It's really just clicking and copy paste from various tutorials. Since I have all the links already researched and discovered for you, it will just take a under an hour to have your own full flown website on the interwebs for cheap - making you awesome!

Set Up Your AWS Account

Just head over to Amazon Webservices and set up an EC2 (Elastic Compute Cloud) instance. This is a virtual server.

AWS Start Page


Setup Your Website

To get everything going, you first just want to get the basic Apache server running.

sudo yum install -y httpd httpd-tools mod_ssl
sudo systemctl enable httpd
sudo systemctl start httpd

Get a Web Address (aka Domain Name)

The domain name is the part of the Internet Address after the typical www. For example, www.example.com has a domain name of example.com. The www part is considered a subnet of the domain. People tend to just have that subnet only as there starting point for their website.

There are many providers out there that sell domain names. Once you own it, you can transfer it to another provider as well. For example, if you got it at GoDaddy, you can transfer it to AWS or CloudDNS. Just try to find one that meets your long term needs as the priceless go up in the second year.
Links:


Setup TSL (aka SSL)

Now that you have a domain name, you need to setup of TSL. This gives you the https designation that prevents allow those nasty security warnings to your visitors. Luckily, this is free and will take care of its updates automatically with LetsEncrypt!

Here is a summary of the commands that will set up your EC2 webserver with TSL:
sudo wget -r --no-parent -A 'epel-release-*.rpm' https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/
sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-*.rpm
sudo yum-config-manager --enable epel*
We need to prep our Apach config file first before installing Certbot, the TSL config app:
sudo nano /etc/httpd/conf/httpd.conf
Paste this into the file you opened with the nano editor replaceing example.com with your domain name:
<VirtualHost *:80>
	DocumentRoot "/var/www/html"
	ServerName "example.com"
	ServerAlias "www.example.com"
</VirtualHost>
sudo systemctl restart httpd #restarts the apache service
sudo yum install -y certbot python2-certbot-apache #installs the TSL app certbot
Finally, run certbot and follow its prompts:
sudo certbot

Make You a Web Page

With Bootstrap styling and an old school text editor, you are on your way to making a very professional site. However, to truly be awesome, you need to use ASP.Net Core to make you a dynamic site like this one. Dynamic means you can put "IF..THEN" logic in your HTML to change the user experience based on conditions such as time of day or season.

ASP.Net Core is already installed on your EC2 Amazon Linux 2 virtual server. So, it's just a matter of setting up Apache to be a Reverse Proxy to your ASP.Net web application you will create.

You are Officially Awesome!

If you made it all the way here, then you are the proud owner of a domain name and web site. Great Work! Keep being awesome.

-Sean and Connor