Nginx is one of the most popular web servers in the world — fast, lightweight and reliable. In this guide we'll walk through installing and configuring nginx on a VPS running Ubuntu, including virtual host setup and SSL certificate.
Step 1 — Install Nginx
Connect to your VPS via SSH and run:
Check if nginx is running:
You should see active (running). Nginx starts automatically on server reboot.
Step 2 — Open Firewall Ports
If you're using UFW firewall, open ports 80 and 443:
With NAT VPS from VPSStorages, ports are managed through NAT rules. Contact support to open additional ports.
Step 3 — Virtual Host
Create a configuration file for your domain:
Add the following content:
Enable the configuration:
Step 4 — Create Directory and Test Page
Step 5 — SSL with Let's Encrypt
Install Certbot for a free SSL certificate:
Certbot automatically updates the nginx configuration for HTTPS. The certificate renews automatically every 90 days.
Step 6 — Performance Optimization
Add the following settings in /etc/nginx/nginx.conf for better performance:
Useful Commands
sudo nginx -t— test configurationsudo systemctl reload nginx— reload without downtimesudo systemctl restart nginx— full restartsudo tail -f /var/log/nginx/error.log— view errorssudo tail -f /var/log/nginx/access.log— view access log
Conclusion
Nginx is a powerful and lightweight web server, ideal for VPS hosting. With proper configuration it can handle thousands of concurrent requests with minimal resource usage. Combine it with VPS Plus from VPSStorages for optimal performance at an affordable price.