Pricing Data Centers
Sign Up Client Portal Configure Server

Installing and Configuring NGINX

Last updated: March 19, 2026 Server Management

Installing NGINX on Ubuntu/Debian

NGINX is a high-performance web server and reverse proxy. Follow these steps to install and configure it on your dedicated server.

Step 1: Update Packages

sudo apt update && sudo apt upgrade -y

Step 2: Install NGINX

sudo apt install nginx -y

Step 3: Start and Enable the Service

sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx

Step 4: Configure a Server Block

Create a new configuration file for your domain:

sudo nano /etc/nginx/sites-available/example.com

Add the following configuration:

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

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

    # Enable gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
}

Step 5: Enable the Site and Test

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

Step 6: Set Up SSL with Let's Encrypt

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com -d www.example.com

Certbot will automatically configure SSL and set up auto-renewal.

Was this article helpful?

Related Articles

Back to Server Management All Categories