Blog
Stay updated with our new news
VPS Hosting 101: How to Use Your Linux VPS to Host a Website
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_IPFrom Windows
You can use:
- Windows Terminal
- PowerShell
- PuTTY
- Any SSH client
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 firewalldsystemctl start firewalld
Allow Required Services (Default Setup)
firewall-cmd –permanent –add-service=sshfirewall-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/tcpReload firewall rules:
firewall-cmd –reloadVerify active rules:
firewall-cmd –list-allYour 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 4096This 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_IPManual method:
On your local machine:
cat ~/.ssh/id_ed25519.pubOn the VPS:
mkdir -p ~/.sshnano ~/.ssh/authorized_keys
Paste the public key, then fix permissions:
chmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keys
Disable Password Authentication
Edit SSH configuration:
nano /etc/ssh/sshd_configEnsure these values:
PermitRootLogin prohibit-passwordPasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
UsePAM no
Restart SSH:
systemctl restart sshdYour 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_configFind:
#Port 22Uncomment and change it, for example:
Port 6934Restart SSH:
systemctl restart sshdConnect using:
ssh root@SERVER_IP -p 6934If 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/tcpfirewall-cmd –reload
Do not close port 22 until you confirm the new port works.
Which Method Should You Use?
| Method | Difficulty | Security |
| Change SSH Port | Easy | Medium |
| SSH Keys Only | Advanced | High |
| Both Together | Advanced | Maximum |
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 -yAlmaLinux / Rocky Linux
dnf update -y7. Install a Web Server (Apache)
Apache is beginner-friendly and widely supported.
dnf install httpd -ysystemctl enable httpd
systemctl start httpd
Visit:
http://SERVER_IPIf 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 -ysystemctl 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:
| Type | Name | Value |
| A | example.ly | SERVER_IP |
| A | www | SERVER_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_htmlchown -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.lyServerAlias www.example.ly
DocumentRoot /var/www/example.ly/public_html
AllowOverride All
Require all granted
Restart Apache:
systemctl restart httpd11. Upload Your Website Files
Place your files in:
/var/www/example.ly/public_htmlTest:
nano /var/www/example.ly/public_html/index.htmlWelcome 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:
- DNS → Domain points to VPS IP
- 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:
More Articles
Stop Using Traditional VPNs: Why Cloudflare Tunnel Is the F…
Data Privacy Day: As Libya Goes Digital, Trust Becomes the…
Beyond Business: ls.gives is Our Commitment to a Better Com…
Leave a Reply