How To Put Your Own Site Online.

Buy a domain, I got mine from google domains, they're pretty low cost, particularly for something unique.

Write your code. Make a git repo. Add all the HTML, CSS, JavaScript, PHP or images anything else you want to put on your webpage into your git repo.

Pick how you want to serve it, you may be able to serve it from home if your web provider allows for public IP use on a home router. Make sure you have the ports open on your local network topology. Alternatively AWS Lightsail is really low cost and easy to use.

Spin up an instance pick your OS, I'm using ubuntu 20.04. Go to the networking tab on the console and give it a static IP, you can have up to 5 static public IPs for free. You'll need a public IP to serve your content to the web. Set network rules, make sure ports 22 for SSH, 80 for HTTP and 443 for HTTPS, are open to both IPv4 and IPv6. SSH in, you can use their browser option or follow the instruction to use PUTTY or another SSH client.

AWS lightsail setup:

Spin up an instance pick your OS, I'm using ubuntu 20.04. Go to the networking tab on the console and give it a static IP, you can have up to 5 static public IPs for free, pretty cool! Set network rules. This is only for serving a static site; if you are using any APIs or doing any file transferring on the same server you may have other ports you need to open.

For both IPv4 and IPv6 open ports:

  • 22 for SSH on TCP & UDP
  • 53 for DNS on TCP & UDP
  • 80 for HTTP on TCP & UDP
  • 443 for HTTPS on TCP & UDP

SSH in:

Go to the AWS lightsail accounts page and then go to the SSH key tab.

Save the default key to Downloads.

Open terminal and input the following commands:

  • cd Downloads
  • sudo chmod 600 defaultKey.pem
  • ls -l

The output will be:

  • -rw------- for your .pem file

Run the command:

  • ssh -i ./defaultKey.pem ubuntu@yourIP
cd new

run the commands:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo ufw status
  • sudo ufw allow 22
  • sudo ufw allow 53
  • sudo ufw allow 80
  • sudo ufw allow 443
  • sudo ufw enable
  • sudo apt-get install nginx
  • sudo systemctl start nginx
  • cd /var/www
  • sudo git clone your_repo
  • cd /your_repo
  • sudo mv my_config_file /etc/nginx/sites-available
  • cd /etc/nginx/sites-available
  • sudo ln -s my_config_file /etc/nginx/sites-enabled
  • sudo systemctl reload nginx

update the google domain with the static public IP wait for your site to go live.

get HTTPS with certbot.