Install Nginx on Linux Server (2026 Production Guide)
Looking to install Nginx on a Linux server for website or API hosting?
This step-by-step guide will help you install, configure, and run Nginx in production.
Whether you're setting up a web server, reverse proxy, or hosting a Node.js/React app — this guide covers everything.
Why Use Nginx?
Nginx is a high-performance web server used for:
- Hosting websites
- Reverse proxy for Node.js apps
- Load balancing
- API hosting
- SSL & HTTPS setup
- High-traffic production servers
It’s lightweight, fast, and used by companies like Netflix, Airbnb, and Cloudflare.
Prerequisites
Before installing Nginx, make sure you have:
- Ubuntu/Linux server (Ubuntu 20.04+ recommended)
- Root or sudo access
- Basic terminal knowledge
- VPS/Cloud server (AWS, DigitalOcean, Hostinger, etc.)
Step 1 — Update Server
Always update packages before installing anything.
sudo apt update && sudo apt upgrade -y
Step 2 — Install Nginx
sudo apt install nginx -y
After installation, verify version:
nginx -v
Step 3 — Start and Enable Nginx
Start Nginx:
sudo systemctl start nginx
Enable auto start on reboot:
sudo systemctl enable nginx
Check status:
sudo systemctl status nginx
Step 4 — Configure Firewall (Important)
Allow HTTP & HTTPS traffic:
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw reload
Check firewall status:
sudo ufw status
Step 5 — Test Installation
Open browser and visit:
http://SERVER_IP
You should see:
Welcome to Nginx page
This confirms Nginx is installed successfully.
Step 6 — Create Server Block (Production Setup)
Create website folder:
sudo mkdir -p /var/www/example.com
Create config file:
sudo nano /etc/nginx/sites-available/example.com
Paste:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
Enable config:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Step 7 — SSL (HTTPS Setup Recommended)
Install certbot:
sudo apt install certbot python3-certbot-nginx -y
Run SSL setup:
sudo certbot --nginx -d example.com -d www.example.com
Now your site runs on HTTPS 🔒
Common Nginx Commands
Restart:
sudo systemctl restart nginx
Reload:
sudo systemctl reload nginx
Stop:
sudo systemctl stop nginx
Need Help with Server Setup?
At Marquefactory, we help startups and businesses:
- Deploy production servers
- Setup Nginx + Node + React
- Configure SSL & security
- Optimize server performance
- Cloud & DevOps automation
👉 Contact us: https://marquefactory.com/#contact
👉 Case studies: https://marquefactory.com/case-studies/
Conclusion
You’ve successfully installed and configured Nginx on Linux server.
Your server is now ready for website or API deployment.
For advanced production deployment, security hardening, and scaling — professional setup is recommended.
Author: Marquefactory DevOps Team
Website: https://marquefactory.com
