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.
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:
Once you log in, update and upgrade your system with the commands below:
sudo apt updatesudo 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 nginxsudo systemctl enable nginx
To verify Nginx is working correctly, you can access the default Nginx welcome page in your browser:
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:
After installation, allow OpenSSH to avoid locking yourself out:
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:
Check your UFW status with:
In your output, you must see:
Status: active To Action From-- ------ ----OpenSSH ALLOW AnywhereNginx Full ALLOW AnywhereOpenSSH (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:
1<!DOCTYPE html>2<html lang="en">3<head>4 <meta charset="UTF-8">5 <title>Welcome to PerLodTest</title>6 <meta name="viewport" content="width=device-width, initial-scale=1.0">7 <style>8 body {9 font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;10 background: #0b1725;11 color: #f5f5f5;12 display: flex;13 align-items: center;14 justify-content: center;15 min-height: 100vh;16 margin: 0;17 }18 .wrapper {19 text-align: center;20 max-width: 600px;21 padding: 24px;22 border-radius: 12px;23 background: rgba(255,255,255,0.04);24 border: 1px solid rgba(255,255,255,0.08);25 }26 h1 { margin-bottom: 8px; }27 p { margin-top: 0; opacity: 0.9; }28 </style>29</head>30<body>31 <div class="wrapper">32 <h1>Static site running on Nginx</h1>33 <p>This page is served from a micro PerLod VPS using Nginx.</p>34 </div>35</body>36</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; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options SAMEORIGIN; add_header X-XSS-Protection "1; mode=block"; 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:
In your output, you must see:
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: 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:
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 { 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; 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 -tsudo 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/htmlsudo chown -R youruser:youruser /var/www/mysite.netsudo 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 -tsudo 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:
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.
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
Why Managed VPS Hosting is Worth the Investment
GPU Passthrough Setup with KVM on VPS