Linux & Infrastructure Read time: 8 min Updated: October 2026

Complete VPS Hosting Guide: Server Selection, Linux Hardening & Web Stacks

When deploying dynamic web applications, microservices, or high-performance APIs, traditional shared web hosting quickly becomes a bottleneck. On shared hosting, server memory, CPU scheduling, and network sockets are distributed among hundreds of unrelated tenants, creating unpredictable latency and restrictive execution limits. Transitioning to a Virtual Private Server (VPS) grants full root access, dedicated system resources, and sovereign control over your operating environment.[1]

This guide provides an end-to-end operational roadmap for deploying a production-ready VPS: hardware sizing, initial user creation, SSH hardening, Uncomplicated Firewall (UFW) configuration, and deploying a secure Nginx reverse proxy with automated TLS certificates.[1][2][3]

1. Comparing Hosting Paradigms: Shared vs. VPS vs. Managed Cloud

Selecting an appropriate hosting tier requires evaluating your technical and operational requirements:

  • Shared Hosting: Inexpensive and simple, but severely restricted. No root terminal access, shared IP reputation, and resource throttling when neighboring sites experience traffic spikes.
  • Virtual Private Server (VPS): Provides dedicated virtualized CPU cores, guaranteed RAM allocations, private IPv4/IPv6 addresses, and complete root administrative privileges using hypervisors like KVM. Suitability depends on availability, operational capacity and workload requirements.
  • Managed Cloud Platforms: Proprietary container platforms (PaaS) offer high abstraction, but carry substantial markup costs and vendor lock-in. Compare total costs, including maintenance, backups and incident response, before choosing a platform.

2. Initial Server Provisioning on Ubuntu Server LTS

For stability and predictable package lifecycles, long-term support (LTS) distributions like Ubuntu Server (22.04 LTS or 24.04 LTS) are standard industry baselines.[1] Once your VPS instance is created, connect as root and update your system package repositories:

# Update package indices and upgrade installed binaries
sudo apt update && sudo apt upgrade -y

# Create an administrative user with sudo privileges
adduser deployer
usermod -aG sudo deployer

3. Hardening SSH Access

Password authentication over port 22 is targeted by automated brute-force scanning bots within seconds of server provisioning. Enforcing cryptographic SSH key pairs and disabling root login eliminates this attack surface:[1]

  1. Generate a modern ED25519 key pair on your local development computer:
    ssh-keygen -t ed25519 -C "admin@rzwan.cloud"
  2. Copy the public key to your new server user:
    ssh-copy-id -i ~/.ssh/id_ed25519.pub deployer@YOUR_SERVER_IP
  3. Edit /etc/ssh/sshd_config to enforce key-only authentication:
    # Inside /etc/ssh/sshd_config
    PermitRootLogin no
    PasswordAuthentication no
    PubkeyAuthentication yes
  4. Restart the SSH service:
    sudo sshd -t
    sudo systemctl reload ssh
Crucial Safety Check: Do not close your existing root terminal session until you verify in a second terminal window that you can successfully log in as deployer using your SSH private key!

4. Configuring the Firewall (UFW)

Linux includes powerful kernel packet filtering via Netfilter/iptables. Ubuntu provides the Uncomplicated Firewall (UFW) frontend to manage incoming and outgoing traffic safely:[1]

# Set default policies: reject unexpected incoming, allow outgoing
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow essential service ports
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

# Enable firewall enforcement
sudo ufw enable
sudo ufw status verbose

5. Deploying and Configuring the Nginx Web Server

Nginx is an event-driven, asynchronous HTTP web server and reverse proxy renowned for low memory consumption and high concurrent throughput.[2]

# Install Nginx
sudo apt install nginx -y

# Enable and start the Nginx service
sudo systemctl enable --now nginx

Create a clean server block configuration file at /etc/nginx/sites-available/rzwan.cloud:

server {
    listen 80;
    listen [::]:80;
    server_name rzwan.cloud www.rzwan.cloud;

    root /home/tableagencyrzwan/htdocs/rzwan.cloud;
    index index.html;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

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

    # Enable gzip compression for fast asset delivery
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml;
}

Link the site configuration to sites-enabled and test the syntax before reloading:[2]

sudo ln -s /etc/nginx/sites-available/rzwan.cloud /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

6. Securing Traffic with Let's Encrypt SSL/TLS

HTTPS protects data in transit and should be part of a public website deployment. HTTPS alone does not establish AdSense eligibility. Certbot automates certificate issuance and renewal via Let's Encrypt:[3]

# Install Certbot with the Nginx plugin
sudo apt install certbot python3-certbot-nginx -y

# Obtain and configure automatic HTTPS certificate
sudo certbot --nginx -d rzwan.cloud -d www.rzwan.cloud

# Verify automated renewal timer
sudo systemctl status certbot.timer

Summary of Core Security Rules

  1. Never use plain password authentication on public SSH endpoints.[1]
  2. Restrict open ports using UFW to only SSH (22), HTTP (80), and HTTPS (443).[1]
  3. Deploy Nginx with gzip compression and strict security headers.[2]
  4. Enforce automated TLS certificate renewals via Certbot.[3]

Primary Sources & Documentation