August 05, 2026 · by CLIQHOST
Nginx is one of the world's most widely used web servers, valued for its speed, low memory footprint, and ability to handle thousands of simultaneous connections. If you're running a SSD VPS or an NVMe VPS and want to host websites or web applications with top performance, Nginx is the right tool for the job.
In this guide, you'll learn how to install Nginx on Ubuntu/Debian and CentOS/AlmaLinux, configure a virtual host, enable HTTPS, and apply key performance optimizations.
Both Nginx and Apache are mature and battle-tested web servers. The key difference lies in their architecture:
On a resource-efficient VPS, this difference is immediately noticeable: Nginx uses significantly less RAM under heavy traffic and serves static files (images, CSS, JS) much faster.
sudo apt update
sudo apt install nginx -y
Start the service and enable it on boot:
sudo systemctl start nginx
sudo systemctl enable nginx
Check the status:
sudo systemctl status nginx
sudo dnf install epel-release -y
sudo dnf install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Using ufw (Ubuntu):
sudo ufw allow 'Nginx Full'
sudo ufw reload
Using firewalld (CentOS/AlmaLinux):
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Open your server's IP address in a browser — you should see the Nginx welcome page.
On Debian/Ubuntu systems, Nginx configuration files are located at:
| Path | Purpose |
|---|---|
/etc/nginx/nginx.conf |
Global configuration |
/etc/nginx/sites-available/ |
Available virtual host configs |
/etc/nginx/sites-enabled/ |
Active configs (symlinks) |
/var/www/html/ |
Default web root |
/var/log/nginx/ |
Access and error logs |
On CentOS/AlmaLinux, virtual host files are typically placed in /etc/nginx/conf.d/.
A server block in Nginx is the equivalent of an Apache virtual host — it lets you host multiple domains on the same server.
Create a configuration file for your domain:
sudo nano /etc/nginx/sites-available/example.com
Minimal working configuration:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html index.php;
access_log /var/log/nginx/example.com_access.log;
error_log /var/log/nginx/example.com_error.log;
location / {
try_files $uri $uri/ =404;
}
}
Create the web root and activate the configuration:
sudo mkdir -p /var/www/example.com
sudo chown -R www-data:www-data /var/www/example.com
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t # test syntax
sudo systemctl reload nginx
Tip: Always run
nginx -tbefore reloading the service. A syntax error can bring down your entire web server.
An SSL certificate is essential today — for both security and SEO. On a Linux VPS, you can get a free certificate using Certbot.
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com -d www.example.com
Certbot will automatically update your Nginx config to include:
- HTTP → HTTPS redirect
- SSL certificate and private key
- TLS security parameters
Certbot sets up a systemd timer or cron job automatically. Test renewal with:
sudo certbot renew --dry-run
If you need a commercial certificate with extended validation or warranty, check out SSL certificates from CLIQHOST — available in DV, OV, and Wildcard options.
If you're running WordPress or any other PHP application, you'll need PHP-FPM. Here's how to integrate Nginx with PHP 8.2:
sudo apt install php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl -y
Add the following inside the server block of your virtual host config:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
Restart both services:
sudo systemctl restart php8.2-fpm
sudo systemctl reload nginx
One of the biggest advantages of an NVMe VPS is that you can squeeze out maximum performance through proper Nginx tuning. Here are the most important settings in /etc/nginx/nginx.conf:
worker_processes auto; # equals number of vCPUs
events {
worker_connections 1024; # connections per worker
use epoll; # optimal for Linux
multi_accept on;
}
http {
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 256;
gzip_comp_level 5;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
client_max_body_size 20M;
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
Nginx writes two types of logs:
Quick command to monitor errors in real time:
sudo tail -f /var/log/nginx/error.log
For professional server administration, CLIQHOST's server management service includes proactive monitoring and rapid incident response.
Before putting your site into production, go through this list:
nginx -t returns no errors.php filescurl -I -H "Accept-Encoding: gzip" https://example.com)Nginx is an excellent choice for any project running on a Linux VPS — from a simple blog to a high-traffic web application. The initial setup takes under an hour, and the performance and stability gains are immediate.
For a solid foundation, choose a high-performance SSD VPS from CLIQHOST or, for more demanding workloads, an NVMe VPS with ultra-low latency. Need help with the setup? Reach out to our team — we're always happy to assist.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."