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:
Bash
sshyouruser@YOUR_SERVER_IP
Or if you still use root, you can run:
Bash
sshroot@YOUR_SERVER_IP
Once you log in, update and upgrade your system with the commands below:
Bash
sudoaptupdatesudoaptupgrade-y
Install and Enable Nginx
You must also install the Nginx web server on your VPS with the command below:
Bash
sudoaptinstallnginx-y
Nginx must be activated during the installation. You can check it with the command below:
Bash
sudosystemctlstatusnginx
If it is not activated, use the commands below to start and enable it:
Bash
sudosystemctlstartnginxsudosystemctlenablenginx
To verify Nginx is working correctly, you can access the default Nginx welcome page in your browser:
Bash
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:
Bash
sudoaptinstallufw-y
After installation, allow OpenSSH to avoid locking yourself out:
Bash
sudoufwallowOpenSSH
Allow the Nginx full profile for both HTTP and HTTPS with the following command:
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.
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:
Bash
sudomkdir-p/var/www/example.com/html
Set the correct ownership so you can manage the files with the following command:
Bash
sudochown-Ryouruser: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:
Bash
sudochmod-R755/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:
Bash
sudonano/var/www/example.com/html/index.html
Add the following minimal static page code to the file:
HTML/XML
1<!DOCTYPE html>2<htmllang="en">3<head>4<metacharset="UTF-8">5<title>Welcome to PerLodTest</title>6<metaname="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<divclass="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:
Bash
sudonano/etc/nginx/sites-available/example.com
Add the following configuration to the file:
Bash
server{listen80;listen[::]:80;server_nameexample.comwww.example.com;root/var/www/example.com/html;indexindex.html;# Basic security headers for static sitesadd_headerX-Content-Type-Optionsnosniff;add_headerX-Frame-OptionsSAMEORIGIN;add_headerX-XSS-Protection"1; mode=block";# Log locationsaccess_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:
Bash
sudorm/etc/nginx/sites-enabled/default
Enable the new site by creating a symbolic link to sites-enabled:
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:
Bash
sudonano/etc/nginx/nginx.conf
Inside the http { … } block, make sure you have something similar to:
Bash
http{# ... existing config ...# Enable gzip compression for text assetsgzipon;gzip_comp_level5;gzip_min_length256;gzip_proxiedany;gzip_varyon;gzip_typestext/plaintext/csstext/javascriptapplication/javascriptapplication/jsonapplication/xmlapplication/rss+xmlapplication/vnd.ms-fontobjectapplication/x-font-ttffont/opentypeimage/svg+xml;# Small micro VPS worker tuningworker_connections1024;keepalive_timeout15;}
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:
Bash
sudonginx-tsudosystemctlreloadnginx
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.
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:
Bash
sudoaptinstallcertbotpython3-certbot-nginx-y
Run Certbot for your domain with the command below:
Bash
sudocertbot--nginx-dexample.com-dwww.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:
Bash
https://example.com
Auto-renewal is installed as a cron job or systemd timer by default. You can simulate a dry run:
Bash
sudocertbotrenew--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:
Bash
sudotail-f/var/log/nginx/example.com.access.log
This displays live traffic to your site. Exit with Ctrl + C.
Error Logs for troubleshooting issues:
Bash
sudotail-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:
Bash
sudosystemctlstatusnginx
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.
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.
Simply replace or upload new files to the site directory, for example:
/var/www/example.com/html
Absolutely. Compression and caching significantly boost performance on low-resource servers. Just ensure your HTML doesn’t change constantly, or configure proper cache headers.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.