# How do I host a website on a VPS?

> How to host a website on a VPS with nginx in 7 steps: DNS records, install, web root, server block, config test, firewall and HTTPS.

- URL: https://saltvps.com/guides/how-to-host-a-website-on-a-vps/
- Last updated: 2026-11-16
- Publisher: SaltVPS (https://saltvps.com)

**Quick answer — How do I host a website on a VPS?**

To host a website on a VPS, point your domain's A and AAAA records at the server, install nginx, put your files in a web root, write a server block, test it with nginx -t and reload. Then open ports 80 and 443 and add HTTPS. Every **SaltVPS** server has 1 dedicated IPv4 for this.

**In brief**

- **DNS first**: an A record for the IPv4 and an AAAA record for an IPv6 from the server's /64.
- **Web server**: nginx from the system repository is enough for static sites and reverse proxying.
- **One file per site** in `/etc/nginx/sites-available/`, linked into `sites-enabled/`.
- **Always test** with `nginx -t` before a reload.
- **HTTPS** comes last, with a free Let's Encrypt certificate.

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

**Example domain: example.com. Commands for Ubuntu and Debian, run as root.**

1. **Point the domain** — At your DNS provider, create an A record for example.com and www with the server IPv4. Add AAAA records if you serve over IPv6.
2. **Install nginx** — Run apt update then apt install nginx. The service starts on its own and serves a default page.
3. **Create the web root** — Run mkdir -p /var/www/example.com and upload your files there, with index.html at the top.
4. **Write a server block** — Create /etc/nginx/sites-available/example.com with listen 80, listen [::]:80, server_name example.com www.example.com, root /var/www/example.com and index index.html.
5. **Enable the site** — Run ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/. Remove the default link if you do not need it.
6. **Test and reload** — Run nginx -t. If it reports the syntax is ok, run systemctl reload nginx.
7. **Open the firewall and add HTTPS** — Run ufw allow 'Nginx Full' to open ports 80 and 443, then request a certificate with certbot.

## Which DNS records does a website on a VPS need?

**Two or four records cover most sites; mail needs its own records and a mail provider.**

*DNS records for a website hosted on a VPS with one IPv4 and an IPv6 range*

| Record | Name | Points to | Needed for |
| --- | --- | --- | --- |
| A | example.com | Server IPv4 | Visitors on IPv4 |
| A | www | Server IPv4 | The www address |
| AAAA | example.com | One IPv6 from the server's /64 | Visitors on IPv6 |
| AAAA | www | Same IPv6 | The www address on IPv6 |
| MX | example.com | Your mail provider's host | Receiving email, handled outside the VPS |

## What does a minimal nginx server block contain?

**Five lines inside a server { } block are enough for a static site:**

- `listen 80;` and `listen [::]:80;`
- `server_name example.com www.example.com;`
- `root /var/www/example.com;`
- `index index.html;`
- `location / { try_files $uri $uri/ =404; }`

For an app that listens on a local port, such as Node.js on 3000, replace the location body with `proxy_pass http://127.0.0.1:3000;`. On AlmaLinux and Rocky Linux, nginx reads extra files from `/etc/nginx/conf.d/` instead of sites-enabled.

## Which VPS plan is best for hosting a website?

**A static site or a small blog runs well on the smallest plans; a dynamic site with a database wants more RAM.** SaltVPS checked its plan list on 16 November 2026: disks run from 40 GB NVMe on Grain to 640 GB NVMe on Dome, with 2 TB to 12 TB of traffic a month. The plan list pairs Flake (1 vCPU / 4 GB / 80 GB) with WordPress, at $4.50 a month on 12 months.

Compare all plans on the [pricing page](https://saltvps.com/pricing/ "How much does a SaltVPS server cost per month?") or read the [self-hosting comparison](https://saltvps.com/best-vps-for-self-hosting/ "Which VPS is best for self-hosting?"). Moving an existing site? The [migration guide](https://saltvps.com/guides/how-to-migrate-a-website-to-a-new-vps/ "How do I migrate a website to a new VPS?") covers files, databases and DNS.

## How do you add HTTPS to the site?

**Run certbot with its nginx plugin once DNS points at the server.** It proves you control the domain, edits the server block and sets up renewal. The [Let's Encrypt guide](https://saltvps.com/guides/how-to-add-free-ssl-with-lets-encrypt/ "How do I add a free SSL certificate with Let's Encrypt?") walks through each command.

One limit to know before you host a website on a VPS here: outbound port 25 is closed on every SaltVPS server. Contact forms and WordPress mail should send through a mail provider on port 465 or 587.

## Hosting a website on a VPS: questions

### Nginx or Apache for a website on a VPS?

Both work. Nginx is lighter for static files and reverse proxying; Apache suits sites that rely on .htaccess files.

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

Yes. Add one server block per domain, each with its own server_name and web root.

### How long until DNS points at the new server?

It depends on the record's TTL. Records with a short TTL change within minutes; older cached answers can last up to the TTL value.

### Where are the nginx logs?

In /var/log/nginx/: access.log for requests and error.log for problems.

### Can I host a WordPress website on a VPS?

Yes. Add PHP-FPM and MariaDB or MySQL next to nginx, and send WordPress mail through an SMTP plugin on port 465 or 587.

**Verdict**

- **Hosting a website on a VPS takes DNS records, nginx, one server block and a certificate.**
- **Plan by RAM**: static sites fit Grain; WordPress and databases fit Flake or larger.

## Sources

1. [nginx beginner's guide](https://nginx.org/en/docs/beginners_guide.html) — nginx.org (2026-11-16)
2. [How nginx processes a request (server names)](https://nginx.org/en/docs/http/request_processing.html) — nginx.org (2026-11-16)
3. [Ubuntu Server documentation: web servers](https://documentation.ubuntu.com/server/) — Canonical (2026-11-16)

**Host your site on your own server** Flake comes with 4 GB of RAM, 80 GB NVMe and a dedicated IPv4, paid in crypto. [Order Flake for 12 months](https://saltvps.com/app/checkout/?plan=flake&term=12m&from=guides-how-to-host-a-website-on-a-vps&lang=en) · [All guides](https://saltvps.com/guides/ "Which VPS guides and Linux tutorials does SaltVPS publish?")

---

SaltVPS: SaltVPS sells Linux KVM VPS in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID document. Seven plans from 2 to 32 GB of RAM cost the same in all six cities, and on the 12-month term each is priced at least 25% under a named comparable plan of a no-KYC crypto host, read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
