Step-by-Step VPS Setup for Web Server A Beginner-Friendly Complete Guide
Your First VPS Feels Empty… Let’s Fix That
So, you just bought a VPS.
You log in using SSH, and suddenly you’re staring at a black screen with a blinking cursor. No control panel, no website, no interface just a terminal.
If this is your first time, don’t panic.
This is exactly how a real server looks at the beginning.
In this guide, we’ll walk through step-by-step VPS installation for a web server, starting from a fresh VPS all the way to a working website that can serve real users.
We’ll use:
- Linux VPS
- Ubuntu Server
- Nginx (recommended)
No shortcuts, no magic scripts just a clean and understandable setup.
What You’ll Learn in This Guide
By the end of this article, you will know how to:
- Access a VPS securely
- Prepare Linux for production use
- Install a web server
- Install PHP and database
- Secure your VPS
- Host your first website
This is a real-world workflow, not a demo.
Step 0: What You Need Before Starting
Before touching the VPS, make sure you have:
- A VPS (any provider is fine)
- Ubuntu Server installed (20.04 / 22.04 LTS recommended)
- VPS IP address
- SSH access (root or sudo user)
- Basic terminal knowledge
This guide assumes a fresh VPS installation.
Step 1: Connect to Your VPS via SSH
From your local machine, open a terminal and connect:
ssh root@your-server-ip
If this is your first connection, type yes to accept the fingerprint.
You are now inside your VPS.
Step 2: Update the VPS System (Always First)
Never skip this step.
apt update && apt upgrade -y
Why this matters:
- Security patches
- Bug fixes
- Stable package versions
A clean, updated system is your foundation.
Step 3: Set Timezone and Basic System Settings
Check timezone:
timedatectl
Set correct timezone (example):
timedatectl set-timezone Asia/Jakarta
Correct time is important for:
- Logs
- SSL certificates
- Cron jobs
Step 4: Create a Non-Root User (Very Important)
Running everything as root is risky.
Create a new user:
adduser webadmin
Give sudo access:
usermod -aG sudo webadmin
Now log in as the new user:
su - webadmin
This is a best practice, even for small servers.
Step 5: Secure SSH Access
Change SSH Configuration
Edit SSH config:
sudo nano /etc/ssh/sshd_config
Recommended changes:
PermitRootLogin no
PasswordAuthentication yes
Restart SSH:
sudo systemctl restart ssh
Now SSH is:
- Safer
- Less exposed to brute-force attacks
Step 6: Enable Firewall (UFW)
Check firewall status:
sudo ufw status
Allow essential services:
sudo ufw allow OpenSSH
sudo ufw allow 80
sudo ufw allow 443
Enable firewall:
sudo ufw enable
Your VPS now blocks unnecessary traffic.
Step 7: Install Web Server (Nginx)
Now the fun part.
Install Nginx:
sudo apt install nginx -y
Start and enable it:
sudo systemctl start nginx
sudo systemctl enable nginx
Test Web Server
Open your browser and visit:
http://your-server-ip
If you see “Welcome to nginx!”, your VPS is officially a web server 🎉
Step 8: Install Database Server (MySQL)
Install MySQL:
sudo apt install mysql-server -y
Secure MySQL:
sudo mysql_secure_installation
Recommended answers:
- Set root password
- Remove anonymous users → YES
- Disable remote root login → YES
- Remove test database → YES
Step 9: Install PHP and Extensions
Install PHP-FPM and common extensions:
sudo apt install php-fpm php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip -y
Check PHP version:
php -v
PHP is now ready.
Step 10: Configure Nginx to Use PHP
Open default site config:
sudo nano /etc/nginx/sites-available/default
Make sure PHP block exists:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
Step 11: Test PHP Integration
Create test file:
sudo nano /var/www/html/info.php
Add:
<?php phpinfo(); ?>
Visit:
http://your-server-ip/info.php
If PHP info page appears, everything works.
Delete the file for security:
sudo rm /var/www/html/info.php
Step 12: Create a Database for Your Website
Login to MySQL:
sudo mysql
Create database and user:
CREATE DATABASE webdb;
CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON webdb.* TO 'webuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Your database is ready.
Step 13: Prepare Website Directory
Create directory:
sudo mkdir -p /var/www/mywebsite
Set permissions:
sudo chown -R www-data:www-data /var/www/mywebsite
sudo chmod -R 755 /var/www/mywebsite
This is where your website files will live.
Step 14: Create Nginx Server Block
Create config file:
sudo nano /etc/nginx/sites-available/mywebsite
Add:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/mywebsite;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
}
Enable site:
sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Step 15: Upload Website Files
Create a simple test site:
sudo nano /var/www/mywebsite/index.php
Add:
<?php echo "Hello, my VPS web server is working!"; ?>
Visit your domain or IP to test.
Step 16: (Optional) Install WordPress
Most VPS web servers are built for WordPress.
Steps overview:
- Download WordPress
- Extract files
- Configure wp-config.php
- Run installation wizard
Your VPS is now WordPress-ready.
Step 17: Enable HTTPS (Strongly Recommended)
Never leave a VPS web server without HTTPS.
Options:
- Let’s Encrypt
- Cloudflare
HTTPS:
- Encrypts traffic
- Improves SEO
- Builds trust
Step 18: Basic VPS Security Hardening
Minimum steps:
- Strong passwords
- SSH key authentication
- Regular updates
- Firewall enabled
- Remove unused services
Security is ongoing not one-time.
Step 19: Monitoring and Maintenance
Useful commands:
htop→ CPU & RAMdf -h→ Disk usagesystemctl status nginx
Check logs regularly.
Common VPS Beginner Mistakes
- No firewall
- Root login enabled
- No backups
- Leaving test files
- Overcomplicating setup
Simple setups are easier to secure.
VPS vs Shared Hosting (Quick Reminder)
VPS gives you:
- Full control
- Better performance
- Learning opportunity
But it also requires:
- Responsibility
- Maintenance
- Attention
Is This VPS Setup Production-Ready?
Yes, for:
- Personal websites
- Blogs
- Small business sites
- Learning projects
For high traffic:
- Add caching
- Optimize PHP-FPM
- Use CDN (Cloudflare)
Why This Step-by-Step Approach Matters
Many tutorials skip steps.
This guide:
- Builds a strong foundation
- Avoids security mistakes
- Teaches real-world skills
Understanding beats copy-paste every time.
Conclusion: Your VPS Is Now a Real Web Server
You’ve successfully turned an empty VPS into a working Linux web server.
You now have:
- A secured VPS
- Nginx web server
- PHP processing
- MySQL database
- A structure ready for real websites
From here, you can:
- Install WordPress
- Optimize performance
- Add HTTPS
- Scale your setup
Your journey into server administration has officially begun