Please watch this youtube video for a more thorough walkthrough.
- Get a domain name. You can buy them from many places, just google "buy a domain name".
- Wherever your domain name is being hosted, whether it be GoDaddy, Google Domains, SquareSpace or otherwise, find where you can set the custom name servers. We'll come back to that later.
- Create an AWS account
- Go to the EC2 dashboard by searching "EC2 in the top bar"
- Create a new EC2 instance, it should be the first option: amazon 2 AMI SSD Volume Type (Make sure itβs free tier eligible)
- Select t2.micro as the instance type. Ignore the warning
- Press launch, and download the key pair. Store your private key in a safe location.
- Download MobaXterm (or some other SSH client) and start a new session.
- Username: ec2-user
- Remote Host: Whatever it says under Public IPv4 DNS on your instance on AWS
- Click Advanced SSH and add your key under use a private key
- You should now be successfully logged into your instance.
- Go back to your insatnce on AWS and go to the security tab
- Click the security group running (there should be only one)
- Click "Edit Inbound Rules"
- Add A new rule with type "HTTP" and source "Anywhere"
- To install NGINX on your EC2 instance type
sudo yum amazon-linux-extras install nginx1
- To start NGINX type
sudo systemctl start nginx
- If you want to check the status of the command type
sudo systemctl status nginx
Now we can successfully visit our Public IPv4 DNS from earlier, and see the default NGINX page. The address should look something like this: ec2-35-83-168-38.us-west-2.compute.amazonaws.com
- Create a new Route53 hosted zone on AWS for your domain.
- Take all the name servers it gives you and put them in for custom name servers on your domain hoster.
- Add an A record under the Route53 which redirects the url to the public IP for your EC2 instance, which should be under the Public IPv4 address listing on your instance dashboard.
Now you should be able to visit your domain name and see the default NGINX HTML page.
- On your instance do
cd /etc/nginx/
- Remove the current nginx.conf file by doing
sudo rm -f nginx.conf
- Create a new nginx.conf file and copy the contents from the file from this repository into it.
- Run
sudo systemctl restart nginx
to reload the config file. - Create a folder anywhere, this will be where our server is located.
- To install node, follow these directions
- Then run
npm init
and press enter to skip through all the settings - Run
node install express
to install express - Create a file called server.js and copy the contents of the server.js file in this directory into it.
- Run node server.js and you're done! Your "webpage" should now be accessible by going to your domain name on a browser.