Docs

First, you'll need to login into your server. You can use WinSCP for your FTP login & PuTTY for SSH. Open PuTTY and fill in your IP into host name and then connect. Then follow the on screen instructions on what user to login as and the password. Your username will most likely be "root" and password was set by you when purchasing or setting up this VPS.

When putting your password, you will not see actual typing for security reasons.

Updating System

Let's start off by making sure our system is up to date with updates, packages, ect.

Run the following command to update.

sudo apt update

Node JS Install

I personally like to use NVM to manage my Node JS versions. You can follow other guides on this but make sure your Node version is above 16 :)

sudo apt update
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Then you'll restart your terminal session by closing it and re-opening it.

Then actually to install Node JS

nvm --version
nvm ls
nvm install 16.13.0
nvm use node

NGINX Install

We'll use NGINX as a reverse proxy for our site. This will be further explained below. For now install like so.

sudo apt install nginx

After prompted, press Y to install.

After that, go to your favorite web browser and make a new tab and type your VPS' IP. You should see the NGINX welcome page. If not then your installation was not correct or NGINX is not started.

MySQL Install

My site does require a MySQL Database to store applications & their data, status, ect.

To install MySQL, use this:

sudo apt install mysql-server

Again, press Y to install.

Now you'll also need the MYSQL secure install by running this

sudo mysql_secure_installation

Read along what is prompted and decide what you would like in the installation. Most of these you can just type Y, but be sure to read.

Certbot Install (SSL)

To make sure your website has a SSL certificate (appears as secure), you'll need Certbot installed for this. Install it like below

sudo apt install certbot python3-certbot-nginx

NGINX Configuration

Credit to FAXES on this part.

Because EJS Websites use NodeJS to function we need to setup a proxy to have our website work on a domain through NGINX. Navigate to your NGINX site config: /etc/nginx/sites-available/default

Insert the below into your config file. Ensure to edit the relevant points. If this is your first time editing this file, you may feel free to delete all other content inside of it, so you start blank before pasting this in.

server {
    
  server_name example.com; # Change domain to yours.
    
  location / {
    proxy_pass http://localhost:3000; # Change the port if changed in the config file.
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
  }    
}

Restart Nginx to make the changes.

sudo systemctl restart nginx

Now let's make an SSL certificate for our domain:

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python3-certbot-nginx

sudo certbot --nginx -d example.com

When prompted, it is advised to pick the second option to route all traffic securely with HTTPS.

If you'd like your SSL to auto renew, you can run this command sudo certbot renew --dry-run

Last updated