-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Jeffrey Arts edited this page Feb 6, 2026
·
14 revisions
This document guides you through my personal preferred set-up for running my project web server, we take a fresh installation of Ubuntu 22.04 as the basis.
sudo apt-get update
# NGINX
sudo apt-get install nginx
# NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 16
# PM2
npm install pm2 -g
# Yarn
npm install yarn -g
# Unzip
sudo apt-get install unzip
# Certbot
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo groupadd web
sudo usermod -a -G web ubuntu
sudo usermod -a -G web www-data
// Add pm2 user to run nodejs applications on an account without root access
sudo adduser pm2
sudo usermod -a -G web pm2
// Optional
sudo adduser <username>
sudo usermod -a -G web <username>
sudo mkdir /var/www/strapi
sudo mkdir /var/www/vite
sudo chown ubuntu:web /var/www/vite
sudo chown ubuntu:web /var/www/strapi
4) Install nginx-helper-scipts
These scripts help to automate some steps for creating NGINX configuration files. Install them for the current user.
if [ ! -d ~/bin ]; then mkdir ~/bin; echo "export PATH=\$PATH:~/bin" >> ~/.bash_profile; fi && cd ~ && git clone https://github.com/JeffreyArts/nginx-helper-functions.git && cp nginx-helper-functions/* ~/bin/ && chmod +x ~/bin/* && source ~/.bash_profile
On default, Ubuntu doesn't allow to loading the entire .bashrc file. This is required though for succesfully running the pm2 deploy script. In order to make that script run succesfully, please comment out (or remove) the following lines in the ~/.bashrc file so they are no longer escaping the script when pm2 tries to load it.
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Make it permanent:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
NGINX Functions
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo tail -f /var/log/nginx/access.log
# Test config file
sudo nginx -t
Add Local SSH Key to Remote Known Hosts
ssh-copy-id <user>@<host>