Deploying Static Websites with Nginx on a Small VPS
A static site is made of fixed files, including HTML, CSS, JavaScript, and images, without server-side code like PHP or databases. Because these sites don’t require heavy processing, even a very small VPS like 256–512 MB RAM can serve them quickly and reliably. Hosting Static Sites via Nginx on a Micro VPS is an easy, affordable, and efficient way to get your site online.
Hosting a static website on a small VPS using Nginx is ideal for personal use, landing pages, documentation sites, or small business pages that don’t need dynamic back-end features.
If you’re using a micro VPS from a provider like PerLod Hosting, this guide will help you set up Nginx, configure domains, secure your site, and optimize performance for static content.
Table of Contents
Prerequisites for Hosting Static Sites via Nginx on a Micro VPS
In this guide, we assume you have a Ubuntu 22.04 OS and a VPS with 1 vCPU, 512 MB, or 1 GB RAM. You must have SSH access as a root or non-root user with sudo privileges and a domain name that points to your server’s IP address.
Connect To VPS and Update System
You must connect to your VPS and update your system. On your local machine, you can run the command below:
ssh youruser@YOUR_SERVER_IP
Or if you still use root, you can run:
ssh root@YOUR_SERVER_IP
Once you log in, update and upgrade your system with the commands below:
sudo apt update
sudo apt upgrade -y
Install and Enable Nginx
You must also install the Nginx web server on your VPS with the command below:
sudo apt install nginx -y
Nginx must be activated during the installation. You can check it with the command below:
sudo systemctl status nginx

If it is not activated, use the commands below to start and enable it:
sudo systemctl start nginx
sudo systemctl enable nginx
To verify Nginx is working correctly, you can access the default Nginx welcome page in your browser:
http://YOUR_SERVER_IP

Enable UFW Firewall on Ubuntu VPS
It is recommended to use the UFW firewall on your system. To install the UFW firewall, you can run the command below:
sudo apt install ufw -y
After installation, allow OpenSSH to avoid locking yourself out:
sudo ufw allow OpenSSH
Allow the Nginx full profile for both HTTP and HTTPS with the following command:
sudo ufw allow 'Nginx Full'
Enable UFW with the command below:
sudo ufw enable
Check your UFW status with:
sudo ufw status
In your output, you must see:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
Point the Domain Name to the VPS
You must point your domain to your VPS by creating an A record in your domain registrar’s DNS settings. This record simply links your domain name to your server’s IP address.
In your domain registrar’s DNS panel, create an A record by following these steps:
- Name (Host): @ or your root domain
- Type: A
- Value: YOUR_SERVER_IP
- TTL: default is fine
If you want www.example.com too, add another A record:
- Name: www
- Type: A
- Value: YOUR_SERVER_IP
Once you have completed these requirements, proceed to the next steps to start Hosting Static Sites via Nginx on a Micro VPS.
Create Nginx Static Site Directory Structure
For your web server to deliver your site’s files, they need to be stored in a specific, organized location. Create the directory with the command below:
sudo mkdir -p /var/www/example.com/html
Set the correct ownership so you can manage the files with the following command:
sudo chown -R youruser:youruser /var/www/example.com
Note: If you are working as the root user and do not have a separate user, skip this chown step.
Apply secure permissions for the directory with the command below:
sudo chmod -R 755 /var/www/example.com
Create a Test HTML Page for the Nginx Static Site
To confirm that your server is set up correctly, you need a file for it to serve. You can create a simple index.html page that will display in a browser once everything is configured correctly.
Create the index.html file in your site’s directory with the command below:
sudo nano /var/www/example.com/html/index.html
Add the following minimal static page code to the file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to PerLodTest</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: #0b1725;
color: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
}
.wrapper {
text-align: center;
max-width: 600px;
padding: 24px;
border-radius: 12px;
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.08);
}
h1 { margin-bottom: 8px; }
p { margin-top: 0; opacity: 0.9; }
</style>
</head>
<body>
<div class="wrapper">
<h1>Static site running on Nginx</h1>
<p>This page is served from a micro PerLod VPS using Nginx.</p>
</div>
</body>
</html>
Press Ctrl + O then Enter to save, and Press Ctrl + X to exit nano.
Create an Nginx Server Block for your Domain
At this point, you must configure Nginx to serve your website by creating a server block similar to a virtual host in Apache. This tells Nginx how to handle requests for your specific domain and where to find your website’s files.
On Ubuntu, Nginx uses sites-available and sites-enabled directories. To create a new server block file, you can run the command below:
sudo nano /etc/nginx/sites-available/example.com
Add the following configuration to the file:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/example.com/html;
index index.html;
# Basic security headers for static sites
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
# Log locations
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
location / {
try_files $uri $uri/ =404;
}
}
Save and exit the file, then disable the default site with the command below:
sudo rm /etc/nginx/sites-enabled/default
Enable the new site by creating a symbolic link to sites-enabled:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Test the configuration for any syntax errors:
sudo nginx -t
In your output, you must see:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Reload Nginx to apply the changes:
sudo systemctl reload nginx
Now you can verify your static page:
http://example.com

Optimize Nginx for Static Content on a Small VPS
Even for lightweight static sites, optimizing Nginx can improve loading times and reduce server resource usage. You can enable gzip compression to make files smaller and adjust some basic settings ideal for micro VPS environments.
Open the main Nginx configuration file with the command below:
sudo nano /etc/nginx/nginx.conf
Inside the http { … } block, make sure you have something similar to:
http {
# ... existing config ...
# Enable gzip compression for text assets
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/plain
text/css
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
font/opentype
image/svg+xml;
# Small micro VPS worker tuning
worker_connections 1024;
keepalive_timeout 15;
}
Notes:
- Don’t add new gzip settings if they’re already in the file, just change the ones that are there.
- Using gzip_comp_level 5 gives a good balance between saving file size and not using too much CPU.
- A keepalive_timeout of 15 seconds works well for small VPS servers. It’s shorter than the default but still safe.
After editing the file, test and reload Nginx with the commands below:
sudo nginx -t
sudo systemctl reload nginx
Host Multiple Websites on One VPS with Nginx
One of the great advantages of a VPS is the ability to host multiple websites on a single server. You can repeat the same process used for your first domain to add as many sites as your resources allow.
For another domain, for example, mysite.net, create the directory and set the correct ownership and permissions:
Note: Make sure DNS A records for mysite.net and www.mysite.net point to your VPS IP.
sudo mkdir -p /var/www/mysite.net/html
sudo chown -R youruser:youruser /var/www/mysite.net
sudo chmod -R 755 /var/www/mysite.net
Create another index.html inside the new folder.
Set up a new Nginx server block with the command below:
sudo nano /etc/nginx/sites-available/mysite.net
For example, add the following content to it:
server {
listen 80;
listen [::]:80;
server_name mysite.net www.mysite.net;
root /var/www/mysite.net/html;
index index.html;
access_log /var/log/nginx/mysite.net.access.log;
error_log /var/log/nginx/mysite.net.error.log;
location / {
try_files $uri $uri/ =404;
}
}
Once you are done, enable and test the configuration:
sudo ln -s /etc/nginx/sites-available/mysite.net /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Enable Free HTTPS with Let’s Encrypt for the Nginx Static Site
Enabling HTTPS is strongly recommended for all websites, because it encrypts traffic between your visitors and your server. Let’s Encrypt provides free SSL certificates that you can easily install using Certbot.
Install Certbot with the command below:
sudo apt install certbot python3-certbot-nginx -y
Run Certbot for your domain with the command below:
sudo certbot --nginx -d example.com -d www.example.com
Certbot will check your Nginx configuration, ask for an email for renewal notices, ask to accept the terms of service, and optionally redirect all HTTP traffic to HTTPS.
Choose the redirect option when asked, so that all traffic goes to HTTPS.
Once it is completed, you can test it in your browser:
https://example.com
Auto-renewal is installed as a cron job or systemd timer by default. You can simulate a dry run:
sudo certbot renew --dry-run
Monitor Nginx Static Site and Check Logs on VPS
Knowing how to monitor your website and check logs is essential for maintenance and troubleshooting. The following commands will help you see real-time traffic, identify errors, and verify that your web server is running properly.
Access Logs show all incoming requests:
sudo tail -f /var/log/nginx/example.com.access.log
This displays live traffic to your site. Exit with Ctrl + C.
Error Logs for troubleshooting issues:
sudo tail -f /var/log/nginx/example.com.error.log
Check this when something isn’t loading correctly. Exit with Ctrl + C.
Verify Nginx is running correctly:
sudo systemctl status nginx
This shows whether Nginx is active, any recent errors, and basic process information.
Note: Replace example.com with your actual domain name.
That’s it, you are done with hosting static sites via Nginx on a micro VPS.
FAQs
Can a micro VPS really handle multiple static websites?
Yes. Static sites require minimal CPU and RAM because they serve pre-built files without backend processing. Even a 512 MB VPS can reliably host multiple static websites using Nginx, as long as you avoid unnecessary services like databases or heavy application servers.
How do I update my static website after deployment?
Simply replace or upload new files to the site directory, for example:/var/www/example.com/html
Are gzip and caching safe for all Nginx static sites?
Absolutely. Compression and caching significantly boost performance on low-resource servers. Just ensure your HTML doesn’t change constantly, or configure proper cache headers.
Conclusion
Hosting a static website on a small VPS using Nginx is a fast, affordable, and reliable way to put your site online. Nginx works very well on low-resource servers because it is lightweight and designed to handle many requests efficiently. By installing Nginx, setting up your server blocks, adding HTTPS, and applying some basic optimizations, you now have a complete and ready-to-use environment for hosting static files.
If you’re looking for affordable VPS plans to host static websites, PerLod offers micro VPS servers perfect for this setup.
We hope you enjoy this guide. Subscribe to our X and Facebook channels to get the latest articles on VPS hosting.
For further reading:
Run Milvus High-Performance Vector Database on VPS