Home/Blog/How to Install and Configure Nginx on Linux VPS (Ubuntu)
Netherlands VPS Guide

How to Install and Configure Nginx on Linux VPS (Ubuntu)

Install Nginx on Ubuntu VPS, configure server blocks, enable HTTPS with Let's Encrypt, and optimise for performance.

2026-01-28 7 min read Amsterdam, Netherlands

Installing Nginx on Ubuntu VPS

SSH into your Netherlands Linux VPS and run:

apt update
apt install nginx -y
systemctl enable nginx
systemctl start nginx

Verify Nginx is running: systemctl status nginx. Open your VPS IP in a browser — you should see the Nginx welcome page.

Configure UFW Firewall

# Allow HTTP and HTTPS
ufw allow 'Nginx Full'
ufw allow OpenSSH
ufw enable
ufw status

Create a Server Block (Virtual Host)

Server blocks in Nginx are equivalent to Apache's virtual hosts — they let you serve multiple domains from one VPS. Create a config file for your domain:

nano /etc/nginx/sites-available/yourdomain.com

Paste this configuration:

server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com;
    index index.html index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }
}

Enable the site and test:

ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

Enable HTTPS with Let's Encrypt

apt install certbot python3-certbot-nginx -y
certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot automatically modifies your Nginx config to redirect HTTP to HTTPS and installs the free SSL certificate. Certificates auto-renew every 90 days via a systemd timer.

Configure PHP-FPM with Nginx

apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring -y
systemctl enable php8.1-fpm
systemctl start php8.1-fpm

Nginx + PHP-FPM is the recommended stack for WordPress on VPS — faster and more memory-efficient than Apache + mod_php.

Performance Optimisation

# Enable Gzip compression in /etc/nginx/nginx.conf
gzip on;
gzip_types text/plain text/css application/json application/javascript;
gzip_min_length 1024;

# Enable browser caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 30d;
    add_header Cache-Control "public, no-transform";
}

Get Your Linux VPS in Amsterdam

Install Nginx in minutes — from $3/month with NVMe SSD

Deploy Netherlands VPS Now

Frequently Asked Questions

Nginx is generally better for VPS because it uses significantly less memory per connection (event-driven vs process-based). Nginx handles 1,000+ concurrent connections with the same memory that Apache uses for 50. For high-traffic sites or VPS with limited RAM, Nginx is the clear choice.
Run: systemctl status nginx. If it shows 'active (running)', Nginx is operational. You can also run: nginx -t to test configuration syntax, and curl -I http://localhost to verify it responds.
Yes. Nginx can act as a reverse proxy in front of Apache, handling static files and SSL termination while passing dynamic requests to Apache. This is the HestiaCP default configuration. However, for simple setups, Nginx-only with PHP-FPM is simpler and more efficient.
Use: systemctl reload nginx (graceful reload, no downtime) or nginx -s reload. Always test configuration first with nginx -t before reloading to avoid taking your site offline with a syntax error.
By default, Nginx listens on port 80 (HTTP) and port 443 (HTTPS). Open these in UFW with: ufw allow 'Nginx Full'. You can also configure Nginx to listen on custom ports for reverse proxy configurations.