Nginx (pronounced “Engine-X”) is a high-performance, open-source web server known for its speed, scalability, and low resource usage. It’s used by giants like Netflix, Dropbox, and WordPress.com—making it one of the most reliable choices for modern web hosting.
But Nginx is more than just a web server:
- It can also act as a reverse proxy
- Load balancer
- API gateway
- And even a mail proxy
If you’re deploying a website or app on a Ubuntu server, installing Nginx is one of the first essential steps.
🧠 Why Choose Nginx?
- Fast: Designed to handle thousands of concurrent connections
- Lightweight: Uses less memory than Apache
- Scalable: Ideal for small blogs to enterprise-level apps
- Versatile: Works as a static file server, reverse proxy, or load balancer
🔧 Perfect for hosting web applications, APIs, and static websites.
💻 How to Install Nginx on Ubuntu
Follow these steps to install and run Nginx on an Ubuntu server (works on versions like 18.04, 20.04, and 22.04).
✅ Step 1: Update Your System
Always start by updating your package list.
sudo apt update
sudo apt upgrade -y
✅ Step 2: Install Nginx
Use Ubuntu’s default APT package manager to install Nginx:
sudo apt install nginx -y
Once installed, you can check its status:
sudo systemctl status nginx
✅ You should see a green “active (running)” status.
✅ Step 3: Allow Nginx Through the Firewall
If you’re using UFW (Uncomplicated Firewall), you need to allow Nginx traffic.
sudo ufw allow 'Nginx Full'
Check the firewall status:
sudo ufw status
✅ Step 4: Verify Installation
Open your browser and go to:
http://your_server_ip
You should see the default Nginx welcome page, confirming it’s running properly.
📁 File Structure of Nginx (Ubuntu)
Knowing where configuration files live is helpful:
Purpose | Location |
---|---|
Main Configuration File | /etc/nginx/nginx.conf |
Site Configurations | /etc/nginx/sites-available/ |
Enabled Sites (symlink) | /etc/nginx/sites-enabled/ |
HTML Root Directory | /var/www/html |
Error Logs | /var/log/nginx/error.log |
🛠 Bonus: Basic Nginx Commands
Command | Description |
---|---|
sudo systemctl start nginx | Start Nginx |
sudo systemctl stop nginx | Stop Nginx |
sudo systemctl restart nginx | Restart after config change |
sudo nginx -t | Test Nginx config file syntax |
sudo nginx -s reload | Reload configuration |
🔐 Pro Tip: Secure Nginx with SSL (Optional)
Once installed, you can easily secure your site using Let’s Encrypt with Certbot:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
Follow the prompts to install free SSL for your domain!
🧠 Final Thoughts
Nginx is a must-have tool in your web server arsenal. Whether you’re hosting a blog, an API, or a high-traffic app, its speed and flexibility make it the top choice. With this guide, you’ve learned what Nginx is and how to install and verify it on Ubuntu like a pro.
Did you install Nginx successfully on Ubuntu?
What will you host with it? Share your project or questions in the comments below! 🧑💻💬