How to create a website

Mar 26, 2020 2 min read
How to create a website

Motivation

Technology changes a lot and while we learn new things and don't practice what we learned before that, we tend to forget. This guide will serve as reference on how to setup a website from ground up.

Requirements

You'll need:

  • Somewhere to host it
  • A CDN managment tool
  • You don't need a domain, but in case you want to ...

All those 3 options can be found here

Setup to get static/dynamic site working

If you want to setup a Blog, go below to the blog section

  1. Go to AWS and create an EC2 server, I like Ubuntu so I always go with the latest version.
  2. Once you log in, go through the Ubuntu setup
  3. To test a simple website, you can create/replace the index.html located at /var/www.
  4. Time to set your own folder to point at the project (use the default url that AWS provides for now):
  • To setup Nginx follow the steps:

You will need a .conf created, located here: cd /etc/nginx/sites-available/. So create one with the name of your site, example: sudo vim mysite.conf and paste inside the following:

server {
     server_name mysite.com www.mysite.com;

     root /var/www/mysite;

     index index.html index.htm;

     location / {
          try_files $uri $uri/ =404;
     }
}

On the URL you can simply type the Public DNS (IPv4) of your EC2 instance or type the actual url of your domain like above :).

Side note: From here on we are going to have https requests because of Certbot, now if you use it in conjunction with Cloudflare, make sure you don't activate all the https features on Cloudflare until the prod env is done, otherwise when you create a new site with it's .conf you won't be able to see it. As a rule of thumb you can simply disable the SSL/TLS encryption mode on cloudflare temporarily so you can see whether the new encrypted site is working or not.

Here is how you setup the DNS on Cloudflare and on AWS - () in case you don't want the protection from Cloudflare.

After modifying the file in /etc/nginx/sites-available, we need to create a link to this file to /etc/nginx/sites-enabled, otherwise nothing of this would work. Go to: /etc/nginx/sites-enabled and type:

sudo ln -s /path/to/source/file

Also make sure your folders have the right permissions:

sudo chmod -R 755 /var/www/site2_web
sudo chmod -R 755 /var/www/site3_web

After that restart Nginx: sudo systemctl restart nginx

If you want to host more than one domain, see here.

  1. Now it's time to get some SSL certificates for our site, I personally use Cerbot but you can also use the free option of Cloudflare

Setup a Blog

So far my favorite is Ghost, there are many ways to install it, here are 2:

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.