Upgrade to Pro

How to Set Up a VPS Server

Setting up a Virtual Private Server (VPS) is an essential skill for website hosting, application deployment, or cloud-based services. This guide will walk you through the process step-by-step, with descriptions, explanations, key points, and images to make the setup easier to understand.


Step 1: Choosing a VPS Provider

Before setting up a VPS, you need to select a hosting provider. Some popular VPS providers include:

  • DigitalOcean

  • Vultr

  • Linode

  • AWS EC2

  • Google Cloud Compute Engine

  • Microsoft Azure

Key Considerations:

  • Server location (Choose the nearest region for better performance)

  • Operating system options (Ubuntu, CentOS, Debian, Windows Server)

  • Pricing and resource allocation (RAM, CPU, storage, bandwidth)

Image: Screenshot of VPS provider selection


Step 2: Creating and Configuring Your VPS

  1. Sign Up & Login: Register an account with your chosen VPS provider.

  2. Create a New VPS Instance:

    • Choose an operating system (Ubuntu 22.04 LTS recommended for beginners)

    • Select your server region

    • Allocate resources based on your needs

    • Set up SSH access

Image: VPS creation screen from DigitalOcean or another provider


Step 3: Connecting to Your VPS via SSH

Once your VPS is deployed, you need to connect using SSH.

For Windows Users:

  1. Download and install PuTTY.

  2. Open PuTTY, enter your VPS IP address, and click Open.

  3. Login with the username (usually root).

For macOS/Linux Users:

  1. Open Terminal.

  2. Run the following command:

    ssh root@your-vps-ip-address
  3. Accept the SSH key fingerprint and enter your password.

Key Points:

  • Ensure port 22 (SSH) is open in your firewall settings.

  • Use sudo for administrative tasks.

  • Consider setting up SSH key authentication for enhanced security.

Image: SSH connection via PuTTY and Terminal


Step 4: Securing Your VPS

Security is crucial for your VPS. Follow these essential steps:

  1. Change the Default Root Password:

    passwd
  2. Create a New User:

    adduser username
    usermod -aG sudo username
  3. Disable Root Login: Edit SSH configuration:

    nano /etc/ssh/sshd_config

    Find PermitRootLogin yes and change it to no.

  4. Enable UFW Firewall:

    ufw allow OpenSSH
    ufw enable
  5. Keep System Updated:

    apt update && apt upgrade -y

Image: Example of secure SSH settings and firewall rules


Step 5: Installing Essential Software

Depending on your needs, install necessary software packages.

  1. Install a Web Server (Apache or Nginx):

    apt install apache2 -y   # For Apache
    apt install nginx -y     # For Nginx
  2. Install a Database Server (MySQL or PostgreSQL):

    apt install mysql-server -y  # MySQL
    apt install postgresql -y   # PostgreSQL
  3. Install PHP (for web applications):

    apt install php php-mysql -y

Image: Installed services running on VPS


Step 6: Setting Up a Domain and SSL

Point Your Domain to VPS

  1. Log in to your domain registrar (e.g., Namecheap, GoDaddy).

  2. Update DNS settings to point the domain’s A record to your VPS IP.

Install Free SSL (Let's Encrypt):

apt install certbot python3-certbot-apache -y
certbot --apache

For Nginx:

apt install certbot python3-certbot-nginx -y
certbot --nginx

Image: Domain DNS settings and SSL installation process


Step 7: Automating Maintenance & Backups

Set Up Automatic Updates:

apt install unattended-upgrades -y

Enable automatic updates:

dpkg-reconfigure --priority=low unattended-upgrades

Schedule Backups with Cron Jobs:

  1. Install a backup tool (rsync, tar, or a cloud backup service).

  2. Schedule automated backups using cron jobs:

    crontab -e

    Add a backup task:

    0 2 * * * tar -czf /backup/backup_$(date +\%F).tar.gz /var/www/html

Image: Example of a backup cron job


Conclusion

Setting up a VPS is a powerful way to host websites, applications, or services while maintaining full control over the environment. By following this guide, you will have a fully functional, secure VPS ready for deployment.

Key Takeaways:

  • Choose a reliable VPS provider with suitable resources. 
  •  Secure your server by disabling root login and enabling a firewall.
  • Install essential software like a web server, database, and PHP.
  • Set up a domain and SSL for security.
  • Automate updates and schedule backups.

Image: Final VPS dashboard with running services

This guide provides a foundational setup. You can expand by installing additional security layers, deploying Docker, or configuring server monitoring tools. 
Flowise Tech https://flowisetech.com