Skip to content

Nginx configuration basics for VPS beginners

By Onehost Team1 min read

Nginx configuration looks intimidating at first, but it follows a simple structure. Here's what a beginner needs to know.

Where config lives

  • /etc/nginx/nginx.conf — the main file.
  • /etc/nginx/sites-available/ — one file per site.
  • /etc/nginx/sites-enabled/ — symlinks to the sites you've turned on.

A minimal server block

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com;
    index index.html;

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

Enable and reload

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t          # always test first
sudo systemctl reload nginx

The golden rule

Always run nginx -t before reloading — it catches syntax errors so you don't take your sites down. Once you understand server blocks and location directives, everything else builds on these basics.

Put it into practice

Let our engineers set up, patch and monitor your web server.

Managed Linux VPS