☁️Hosting·7 min read

Ubuntu Raw VPS Guide

Set up a clean Ubuntu server from scratch for custom deployments.

The Ubuntu blueprint gives you a clean Ubuntu server with no pre-configured applications. Everything is up to you.

First Steps After Login

SSH into your server:

ssh -i your-key.pem ubuntu@YOUR-IP

Update your system:

sudo apt update && sudo apt upgrade -y

Setting Up a Firewall

sudo ufw allow OpenSSH

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp

sudo ufw enable

sudo ufw status

Installing a Web Server

Apache:

sudo apt install apache2 -y

sudo systemctl enable apache2

Nginx:

sudo apt install nginx -y

sudo systemctl enable nginx

Installing PHP

sudo apt install php php-fpm php-mysql php-curl php-gd php-mbstring -y

Installing MySQL

sudo apt install mysql-server -y

sudo mysql_secure_installation

Installing Node.js

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

sudo apt install nodejs -y

node --version

Installing Docker

sudo apt install docker.io docker-compose -y

sudo usermod -aG docker ubuntu

# Log out and back in for group changes

Setting Up a Non-Root User

sudo adduser deployer

sudo usermod -aG sudo deployer

sudo su - deployer

mkdir -p ~/.ssh

# Copy your authorized_keys

Securing the Server

1.Disable root login:

sudo nano /etc/ssh/sshd_config

Set: PermitRootLogin no

sudo systemctl restart sshd

2.Install Fail2Ban:

sudo apt install fail2ban -y

sudo systemctl enable fail2ban

3.Enable automatic security updates:

sudo apt install unattended-upgrades -y

sudo dpkg-reconfigure -plow unattended-upgrades

Setting Up Swap Space

For instances with limited RAM:

sudo fallocate -l 2G /swapfile

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile

echo '/swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab

Monitoring

htop — Interactive process viewer

df -h — Disk usage

free -m — Memory usage

sudo journalctl -xe — System logs

Knowledge Base — NexusHost | NexusHost