Host a website on a VPS: nginx, Let's Encrypt SSL and your domain
Hosting a site on your own VPS gives you full control and is simpler than it sounds. This guide uses Ubuntu or Debian commands, which can vary on other distributions.
1. Point your domain at the VPS
In your domain registrar's DNS settings, add an A record.
- Type A, name @, value YOUR_SERVER_IP
- Add a second A record with name www and the same IP
- Wait for DNS to update, which can take minutes to a few hours
Check with dig +short yourdomain.com or nslookup yourdomain.com. If your server has an IPv6 address, an AAAA record works the same way.
2. Install nginx
- sudo apt update
- sudo apt install nginx -y
- sudo ufw allow 'Nginx Full' if you use UFW
- Open http://YOUR_SERVER_IP and look for the welcome page
3. Create your site
- sudo mkdir -p /var/www/yourdomain.com
- Put an index.html file in that folder
- sudo nano /etc/nginx/sites-available/yourdomain.com
Use this server block:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/yourdomain.com;
index index.html;
}
Remove the braces formatting concerns by keeping it exactly as nginx expects, with a semicolon after each line and the block closed.
- sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
- sudo nginx -t
- sudo systemctl reload nginx
4. Add free HTTPS
Let's Encrypt issues free certificates, and certbot automates it. Your DNS must already point at the server.
- sudo apt install certbot python3-certbot-nginx -y
- sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
- Choose to redirect HTTP to HTTPS when asked
- sudo certbot renew --dry-run to test automatic renewal
Troubleshooting
- 502 or 404: check sudo nginx -t and the logs in /var/log/nginx/error.log
- Certbot fails: confirm port 80 is open and the A record is correct
- Old page showing: clear cache or wait for DNS
Tips
- Keep file ownership tidy with sudo chown -R www-data:www-data /var/www/yourdomain.com
- Enable gzip and caching later for speed
- Back up your site folder regularly
Tabi Cloud offers 24/7 uptime, and you can ask us for help over Discord ticket or email.