Skip to main content

Blog

Stay updated with our new news

VPS Hosting 101: How to Use Your Linux VPS to Host a Website

c10eb69144e8bef366c7ad37e5dc2b697d0b18e5daf701b0fab8d2eab7ab809a?s=96&d=mm&r=g
Osama Algabsi | 26/02/2026 |
blog en copy 6 2 4f7dcf2c

What is a VPS?

A Virtual Private Server (VPS) is a high-performance hosting solution that uses virtualization technology to provide you with dedicated (private) resources on a server with multiple users. While you share the physical hardware with others, your VPS operates as a completely independent instance with its own Operating System (OS), dedicated RAM, and CPU allocation.

Unlike standard shared hosting, a VPS gives you Root Access, allowing you to install custom software, configure deep security settings, and scale your resources as your project grows. It is the industry standard for developers and businesses that require the control of a dedicated server at a fraction of the cost.

Buying a VPS (Virtual Private Server) is an exciting step—but for many clients, the first question is:

“Okay… I bought the VPS. Now what?”

This article is VPS Hosting 101. It explains, step by step, how to use your Linux VPS to securely host a website—from the moment your VPS is created until your domain is live and serving content.

Focus: Linux VPS (Ubuntu, AlmaLinux, Rocky Linux)
Goal: Secure, production-ready website hosting
Level: Beginner → Intermediate

1. What Happens After You Buy a VPS?

When you purchase a VPS from Libyan Spider, everything is automated and fast.

VPS Provisioning (Behind the Scenes)

  • A virtual machine (VM) is created on LS Cloud infrastructure
  • CPU, RAM, and disk are allocated based on your selected package
  • The operating system you chose is installed on a dedicated volume
  • The VPS is fully ready in under 30 seconds

No manual setup. No long waiting time.

2. Your VPS Access Email (Important)

Once provisioning is complete, you’ll receive an email containing:

  • Server IP address
  • Username (usually root)
  • Password
  • SSH port: 22

Servers running cPanel may include additional details (covered in a separate article).

Keep this email secure—it’s your server’s initial access.

3. Connecting to Your VPS Using SSH

SSH (Secure Shell) is how you remotely control your VPS.

From Linux or macOS

ssh root@SERVER_IP

From Windows

You can use:

  • Windows Terminal
  • PowerShell
  • PuTTY
  • Any SSH client
ssh root@SERVER_IP -p 22

Once logged in, you have full control over the server.

4. First Priority: Secure Your VPS (Firewall Configuration)

Before changing SSH settings or installing software, set up the firewall first.
This ensures you don’t accidentally lock yourself out later.

Firewall Configuration (AlmaLinux / Rocky Linux)

AlmaLinux and Rocky Linux use firewalld by default.

Enable firewalld

systemctl enable firewalld
systemctl start firewalld

Allow Required Services (Default Setup)

firewall-cmd –permanent –add-service=ssh
firewall-cmd –permanent –add-service=http
firewall-cmd –permanent –add-service=https

(Optional) If You Plan to Change the SSH Port

Example: SSH on port 6934

firewall-cmd –permanent –add-port=6934/tcp

Reload firewall rules:

firewall-cmd –reload

Verify active rules:

firewall-cmd –list-all

Your VPS is now accessible only on required ports:

  • 22 (SSH – default)
  • 80 (HTTP)
  • 443 (HTTPS)
  • Custom SSH port (if added)

5. Secure SSH Access (SSH Hardening)

Before installing anything else, secure SSH access.
There are two common methods. You can use one or both, depending on your experience level.

5.1 Method 1: Secure SSH Using SSH Keys

(Advanced – Recommended for Experienced Users)

SSH key authentication is the most secure method.

Be careful—misconfiguration can lock you out of your VPS.

Create an SSH Key Pair (On Your Computer)

Run this on your local machine, not on the VPS:

ssh-keygen -t ed25519 -C “[email protected]

Alternative:

ssh-keygen -t rsa -b 4096

This creates:

  • Private key: ~/.ssh/id_ed25519
    Keep it secret and secure on your machine
  • Public key: ~/.ssh/id_ed25519.pub
    Safe to copy to the server

Copy the Public Key to the VPS

Automatic method (recommended):

ssh-copy-id root@SERVER_IP

Manual method:

On your local machine:

cat ~/.ssh/id_ed25519.pub

On the VPS:

mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys

Paste the public key, then fix permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Disable Password Authentication

Edit SSH configuration:

nano /etc/ssh/sshd_config

Ensure these values:

PermitRootLogin prohibit-password
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
UsePAM no

Restart SSH:

systemctl restart sshd

Your server now accepts SSH keys only, blocking brute-force attacks.

Always confirm key login works before closing your session.

5.2 Method 2: Change the Default SSH Port

(Simple & Beginner-Friendly)

By default, SSH listens on port 22, which is heavily scanned by bots.
Changing it reduces automated attacks.

Change SSH Port

Edit the SSH config:

nano /etc/ssh/sshd_config

Find:

#Port 22

Uncomment and change it, for example:

Port 6934

Restart SSH:

systemctl restart sshd

Connect using:

ssh root@SERVER_IP -p 6934

If you changed the SSH port, make sure to open connection to this port from the server firewall by running this command

firewall-cmd –permanent –add-port=6934/tcp
firewall-cmd –reload

Do not close port 22 until you confirm the new port works.

Which Method Should You Use?

MethodDifficultySecurity
Change SSH PortEasyMedium
SSH Keys OnlyAdvancedHigh
Both TogetherAdvancedMaximum

Beginners can start with changing the SSH port
Advanced users should use SSH keys + custom port

6. Update Your System Packages

Always update your OS before installing software.

Ubuntu / Debian

apt update && apt upgrade -y

AlmaLinux / Rocky Linux

dnf update -y

7. Install a Web Server (Apache)

Apache is beginner-friendly and widely supported.

dnf install httpd -y
systemctl enable httpd
systemctl start httpd

Visit:

http://SERVER_IP

If you see the Apache test page → Web server is running.

8. Install a Database Server

For most websites, MySQL / MariaDB is the best choice.

dnf install mariadb-server -y
systemctl enable mariadb
systemctl start mariadb
mysql_secure_installation

Works for WordPress, Laravel, Joomla, and most CMS platforms.

9. Connect Your Domain to the VPS (DNS Setup)

When you buy a domain from Libyan Spider, you receive Premium DNS Hosting for free.

Add an A record in the DNS Zone Manager:

TypeNameValue
Aexample.lySERVER_IP
AwwwSERVER_IP

DNS propagation usually takes 5–30 minutes.

10. Configure Apache for Your Domain (Virtual Host)

DNS alone is not enough—you must configure the web server.

10.1 Create Website Directory

mkdir -p /var/www/example.ly/public_html
chown -R apache:apache /var/www/example.ly
chmod -R 755 /var/www/example.ly

10.2 Create Apache Virtual Host

nano /etc/httpd/conf.d/example.ly.conf ServerName example.ly
ServerAlias www.example.ly
DocumentRoot /var/www/example.ly/public_html
AllowOverride All
Require all granted

Restart Apache:

systemctl restart httpd

11. Upload Your Website Files

Place your files in:

/var/www/example.ly/public_html

Test:

nano /var/www/example.ly/public_html/index.html

Welcome to my VPS 🚀

Visit: http://example.ly

Your website is live

12. DNS vs Web Server (Key Concept)

To host a website, both steps are required:

  1. DNS → Domain points to VPS IP
  2. Web Server → Apache maps domain to a directory

Missing either step = website won’t work.

Final Thoughts

You now have:

  • Secure SSH access
  • Firewall protection
  • Domain connected via Premium DNS Hosting
  • Apache serving your website
  • A solid, production-ready VPS foundation

This is how professionals deploy websites on a VPS.

Share:

FacebookTwitterLinkedInWhatsAppTelegramViberCopy Link
Leave a Reply

Your email address will not be published. Required fields are marked *