Dojo Wudan
posts   tags   about  

Getting your website up and running

So you have seen my posts about creating your VPN, SSH key, rsync and all, but you dont even have a website? Makes sense, because I should have posted this post earlier.

So lets go under and hour, we will have our basic webpage up and running on our VPS server.

  1. Get your domain name

I suggest njal.la as they do not share your whois. Simple interface, everything is nice. Choose whatever you want and buy it.

  1. Get a server

There are tons of server options. Server means, there is a computer which has your files constantly broadcasting to internet. You can use this server as a website host, email server, file-sharing service, mirc server.. and much more

So lets go get a VPS (Virtual Personal Server)

I am using 1984.hosting again extremely simple interface, located in iceland, fast support, relatively cheap. A basic VPS will cost you around 5euro per month.

You can use others like digitalocean, Vultr, Privex and much more.

So lets create a VPS, select debian a server operating system with no addons. About server size, first choose the cheapest option, they will let you expend if you need more.

Also enable IPv6 for future.

  1. Connect your Domain and Server

Open your domain registrar and DNS records.

Put your server’s IPv4 address to A and IPv6 address to AAAA value. Save and after couple of minutes (sometimes and hour) test with terminal

ping yourdomain.net if you see the same IP with your server, then everything is ok.

  1. Set up NginX webserver

Login to your server

ssh root@yourdomain.net

If you cannot, it means your DNS settings are not correct, or it is not updated yet, check step 3.

First update packages, then install nginx.

1
2
3
apt update
apt upgrade
apt install nginx

Create a file in /etc/nginx/sites-available by

nano /etc/nginx/sites-available/mywebsite

then add following content into it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
server {
        listen 80 ;
        listen [::]:80 ;
        server_name yourdomain.net ;
        root /var/www/mysite ;
        index index.html index.htm index.nginx-debian.html ;
        location / {
                try_files $uri $uri/ =404 ;
        }
}

Create the directory for your website:

mkdir /var/www/mysite

nano /var/www/mysite/index.html

1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<body>

<h1>My ultimate website</h1>
<p>is going lit!</p>

</body>
</html>

Enabling the website:

ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled

and reload nginx service

systemctl reload nginx

The Firewall:

Just to be on the safe side install firewall and allow website and mail ports as well as yourself.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
apt install ufw
ufw default deny incoming
ufw allow in ssh
ufw enable
ufw allow 80
ufw allow 443
ufw allow http
ufw allow https
ufw allow in IMAPS
ufw allow in POP3
ufw allow in SMTP
ufw allow in 'Postfix SMTPS'
ufw allow in 'Mail Submission'
ufw reload
  1. Certbot and HTTPS

To enable encrypted connections over HTTPS/SSL we need to do these:

apt install python3-certbot-nginx

certbot --nginx

Do not use or give your mail address, no need. It is all done, now lets create certificate renewal:

crontab -e

add 0 0 1 * * certbot --nginx renew to end of the line and save this.

VOILA!

Now you have a server, and a basic intro webpage up and running.


🌊⛰🔥