I started hosting my web development practice site on Hostinger, with a domain name bought from Namecheap, following a 'reddit tip' that I read to not buy a domain name and host the website with the same company.
Exploring this topic of web development and hosting even more, I discovered that I may want more funcitonality with my website.
I just learned what it means to be a 'Back-end' developer vs a cloud developer/engineer: Back-end still deals with the code that you write on your IDE, but more towards managing the flow of data between the server and interface, say the comments on a comment box being collated in a database when you click the 'submit button'.
A cloud developer deals with the monster called 'Amazon Web Service (AWS)', which is actually more of an umbrella term for a bunch of products and services, rather than a single product.
AWS to the cloud industry is what Autodesk is to the CAD industry: with Autodesk you have Revit, Fusion 360, Maya, 3DS Max, Navisworks, etc... basically product names which don't tell you what they can do for you, so you have to read up on them to find out what they do. I'm not going to cover what products AWS offers, because it is huge and confusing, but I will talk about the Elastic Compute Cloud (EC2).
Amazon Web Service Elastic Compute CLoud (AWS EC2)
This is basically a virtual machine, which in other words is a computer virtually created by Amazon in their data centres, the screen/terminal of which you can access from tyour web browser. When you create the 'instance' which is what each virtual computer is called, you can specify whether it should install a Linux system, a Windows system, and many others.
Following the typical youtube tutorial (there are many of them), and chatgpt answers, I went with Ubuntu with Apache2.
There are other services like Lightsail, S3, Bucket, but I felt that EC2 would allow me to expand, since it literally is a computer of its own, and I can install whatever software the linux OS allows me to install. This makes way for opportunity to do fancy over-engineered stuff with my practice website like Machine Learning apps, heavy animations, games, etc...
Hostinger
I made the mistake of subscribing for 4 years, paying up front about USD 180, which is 'relatively' cheap, but also 'relatively' expensive if you consider that you could be paying zero dollars, and I felt that I may outgrow it within a year. Thankfully Hostinger allows you to apply for refund within 30 days from making a purchase. I will still consider Hostinger for simpler, lighter static websites that I may need in the future, since a full blown linux machine is a bit overkill if I just want to host a blog, the complexity is just as such:
Setting up AWS EC2 for Github auto-deployment
Is a pain in the ***e.
With hostinger I just need to copy a bunch of lines to github and hostinger, allow webhook, and done.
First, you have to create the virtual machine 'instance', which have a lot of options. Choose operating system, setup the firewall (if you mess up, you won't know if it's the initial setup that is the problem, or a config file in the pc, or your domain name, etc).
Second, you have to install and configure the Apache2 server software. You have folder structure and config files that you have to manually create yourself.
Third, get your website files into the EC2 instance.
If you want to do it via github, you need to use this thing called 'Github Actions', which is a rabbit hole in itself. Then you have to play with SSH Key Pairs, which are basically a pair of codes that you have to key in to github and make sure is in your EC2 instance as well otherwise EC2 will not allow github to connect.
If you firewall settings is wrong, this will fail; if your Apache2 config is wrong, this will fail; if your Github/EC2 key pairs are wrong, this will fail; if yoru Github Actions setup is wrong, this will fail. My setup is still failing, so for now I just cloned the github repo manually from the EC2 instance itself, and moved it to the proper location.
Pointing the Namecheap domain name to the AWS EC2 server
There are a couple of ways to do this as well.
- Copy the public IP address of the EC2 instance and go to the advance DNS setting of the namecheap domain, paste it in for a 'DNS Type A record', or:
- Setup a 'hosting zone' in another AWS service/product called Route 53, which is basically just AWS' version of their own Hostinger or Namecheap daomin/hosting service. Then, this hosting zone will give you the nameserver address, which you add onto the namecheap domain settings.
- Just create a new domain name with Route 53.
Three options: one involves one service, next only involves two services, another involves three. I don't know the pros and cons, but one thing I do know is that I still can't connect to my website via the domain name. But it's only been less than 48hrs, which according to dnslookup, the internet and chatgpt, is about the time needed for the DNS to 'propagate'. So I'll wait 2 days and check again. In the meantime, my website can still be viewed via the Public IP address of the EC2 instance, so it's what I'm sharing right now.
The end~