# How do you host a website on a VPS with nginx and HTTPS?

> How to host a website on a VPS: point DNS to the IP, install nginx, add a server block, open ports 80 and 443, then add free HTTPS with Certbot.

- URL: https://buymonerovps.com/guides/how-to-host-a-website-on-a-vps/
- Last updated: 2026-11-30
- Publisher: BuyMoneroVPS (https://buymonerovps.com)

**Quick answer**

To host a website on a VPS, point your domain's DNS A record to the server's IP, install nginx, add a server block with your domain and a web root, open ports 80 and 443, then run Certbot for a free Let's Encrypt certificate that renews itself. On a **BuyMoneroVPS** Debian or Ubuntu server it takes about 30 minutes.

**In brief**

- A static site or a small CMS runs well on Ring 1 or Ring 2; databases and many visitors want Ring 4.
- nginx picks the server block whose server_name matches the requested host.
- Let's Encrypt's HTTP-01 check works only on port 80, so keep port 80 open even after HTTPS works.
- Certbot installs a timer or cron job that renews certificates before they expire.

## What do you need before installing anything?

**A domain name, a VPS with a public IP, and five minutes at your registrar.** Create an A record for the domain, and another for www if you want it, pointing to the server's IPv4 address from the dashboard. Every BuyMoneroVPS server also has a /64 of IPv6, so you can add an AAAA record for one address in that range once the site answers on IPv6.

DNS changes take time to spread, from minutes to a few hours depending on the old TTL. Prepare the server meanwhile: updates, a sudo user, key-only SSH and ufw, as in [securing a new Linux VPS](https://buymonerovps.com/guides/how-to-secure-a-new-linux-vps/ "How to secure a new Linux VPS"). Certbot will only succeed once the domain resolves to the server, so check with a quick lookup before the HTTPS step.

## What are the steps from a blank server to HTTPS?

1. **Point the domain to the server** — Create A records for example.org and www.example.org with the VPS IPv4 address.
2. **Install nginx** — Install the nginx package from Debian or Ubuntu. It starts at once and serves a default page on port 80.
3. **Create the web root** — Make a folder such as /var/www/example.org, put an index.html in it, and give it to your deploy user.
4. **Add a server block** — Write a file in /etc/nginx/sites-available/ with listen 80, server_name for both names, root and a location block. Link it into sites-enabled.
5. **Test and reload nginx** — Run nginx -t to check the syntax, then reload. Open http://example.org: your page should appear.
6. **Open the firewall** — Allow 80/tcp and 443/tcp in ufw. Port 80 must stay open for certificate checks.
7. **Get the certificate with Certbot** — Install Certbot, then run certbot --nginx. It asks which names to cover, proves control of the domain and edits the server block for HTTPS.
8. **Test the renewal** — Run certbot renew --dry-run. If it succeeds, the installed timer will renew the certificate on its own.

*Install nginx and create the site (as root or with sudo)*

```bash
apt update && apt install -y nginx
mkdir -p /var/www/example.org
echo '<h1>It works</h1>' > /var/www/example.org/index.html
nano /etc/nginx/sites-available/example.org     # paste the server block below
ln -s /etc/nginx/sites-available/example.org /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
ufw allow 80/tcp && ufw allow 443/tcp
```

*/etc/nginx/sites-available/example.org*

```nginx
server {
    listen 80;
    listen [::]:80;
    server_name example.org www.example.org;

    root /var/www/example.org;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
```

*HTTPS with Certbot (snap install, as Certbot's instructions show)*

```bash
apt install -y snapd           # Debian: snapd is not always present
snap install --classic certbot
ln -s /snap/bin/certbot /usr/local/bin/certbot
certbot --nginx -d example.org -d www.example.org
certbot renew --dry-run
```

## Which plan fits which kind of site?

*BuyMoneroVPS plans for common website loads, with 30-day prices, 30 November 2026*

| Site | Suggested plan | Resources | Price for 30 days |
| --- | --- | --- | --- |
| Static site, blog generator output | Ring 1 | 1 vCPU / 1 GB / 20 GB | $3.78 |
| Small CMS with a database | Ring 2 | 1 vCPU / 2 GB / 40 GB | $5.51 |
| Several sites, shop, heavier CMS | Ring 4 | 2 vCPU / 4 GB / 80 GB | $9.12 |
| US visitors, low latency in America | Hub 4 | 2 vCPU / 4 GB / 65 GB | $8.18 |

## How does nginx choose which site to serve?

**By the host name the visitor asked for: the server block whose server_name matches wins.** nginx's documentation on server names explains that the directive decides which server block handles a request, with exact names checked before wildcards and regular expressions. That is how one VPS hosts several sites: one file per domain in sites-available, each with its own server_name and root.

Inside a block, location blocks map URLs to files. The nginx beginner's guide shows a location / with a root: the request path is appended to the root to find the file on disk. Changes take effect only after a reload, so the habit is always the same: edit, nginx -t, reload. A syntax error caught by nginx -t never reaches visitors.

## How does the free certificate stay valid?

**Certbot installs its own timer or cron job and renews the certificate before it expires.** Certbot's instructions state that you will not need to run it again unless you change your configuration, and suggest certbot renew --dry-run to test the process. The renewal command sits in /etc/crontab, a file in /etc/cron.* or the list shown by systemctl list-timers.

The check behind each renewal uses Let's Encrypt's HTTP-01 challenge, which places a file under /.well-known/acme-challenge/ on your domain and, according to Let's Encrypt, can only be done on port 80. Closing port 80 after HTTPS works breaks the next renewal; let nginx redirect HTTP to HTTPS instead, which Certbot can set up for you.

According to BuyMoneroVPS's survey of 30 November 2026, Ring 2 (1 vCPU / 2 GB / 40 GB) costs $5.51 against a $11.15 mean for comparable plans. The [self-hosted apps use case](https://buymonerovps.com/use-cases/self-hosted-apps/ "Self-hosted apps on a Monero VPS") compares plans for heavier software, and the [ufw firewall guide](https://buymonerovps.com/guides/how-to-set-up-a-ufw-firewall/ "How to set up a UFW firewall") covers the rules used here.

## Frequently asked questions

### Can I host several websites on one VPS?

Yes. Create one server block per domain, each with its own server_name and root, and run Certbot for each domain. Watch memory use as you add sites, and move to a bigger plan when it runs short.

### How soon can the site be online after I pay?

About 20 minutes for the 10 Monero confirmations, up to 1 hour for a person to build the server, then roughly 30 minutes of setup with this guide. DNS propagation can add a little more.

### Can I send email from the website?

Outbound port 25 is open, so a contact form can send mail. Spam and bulk email are forbidden by the acceptable use policy.

### I moved from another host. What about my old files?

Copy them with rsync and move the database as a dump, then switch DNS. The [migration guide](https://buymonerovps.com/guides/how-to-migrate-a-server-to-a-new-vps/ "How to migrate a server to a new VPS") lists the commands.

### Can I use Apache instead of nginx?

Yes. Certbot has an Apache mode too. This guide uses nginx because its configuration for one or several static or proxied sites stays short.

**Verdict**

- DNS first, then nginx, then Certbot: in that order the HTTPS step works the first time.
- Keep port 80 open for renewals and redirect it to HTTPS.
- Ring 1 or Ring 2 is enough for most personal and small business sites.

## Sources

1. [Beginner's Guide](https://nginx.org/en/docs/beginners_guide.html) — nginx (read 2026-11-30)
2. [Server names](https://nginx.org/en/docs/http/server_names.html) — nginx (read 2026-11-30)
3. [Certbot instructions, nginx on Linux (snap)](https://certbot.eff.org/instructions?ws=nginx&os=snap) — Electronic Frontier Foundation (read 2026-11-30)
4. [Challenge Types](https://letsencrypt.org/docs/challenge-types/) — Let's Encrypt (read 2026-11-30)

**Host your site on a Monero VPS** Ring 2: 1 vCPU · 2 GB memory · 40 GB NVMe disk · 4 TB monthly transfer, dedicated IPv4, paid in XMR with no ID.

- [Deploy Ring 2 for $5.51](https://buymonerovps.com/app/checkout/?plan=ring-2&term=1m&from=guides-how-to-host-a-website-on-a-vps&lang=en)
- [Compare all plans](https://buymonerovps.com/pricing/ "BuyMoneroVPS pricing: what does a Monero VPS cost?")

---

BuyMoneroVPS: BuyMoneroVPS sells Linux KVM virtual servers paid in Monero first, and also in Bitcoin, Litecoin, Solana, Ether, USDC and USDT, with no ID check and no email required. Servers run in Amsterdam, Reykjavik, Zurich, Bucharest, New York, Dallas, Los Angeles, London, Frankfurt, from $3.78 a month. BuyMoneroVPS LLC, a New Mexico company, runs the service.
