How To Install Nginx On Debian 13 Trixie

How To Install Nginx On Debian 13 Trixie

Nginx is one of the most widely used web servers in the world, known for its high performance, lightweight resource usage, and excellent stability for high-traffic websites. On Debian 13 (Trixie), installing Nginx is straightforward because the official repository already provides an up-to-date version.

This article provides a complete guide on how to install, configure, and run Nginx on Debian 13, suitable for beginners and server administrators.

1. Update Your Debian 13 System

Before installing Nginx, update your system packages :

sudo apt update && sudo apt upgrade -y

This ensures your server has the latest dependencies.

2. Install Nginx On Debian 13

Debian 13 includes Nnginx directly in its official repository. Install it with :

sudo apt install nginx -y

Once finished, Nginx will be installed and ready to use.

3. Check Nginx Service Status

Verify that Nginx is running :

sudo systemctl status nginx

If it's active, you should see :

active (running)
4. Enable Nginx To Start Automatically

Ensure Nginx runs on every server reboot :

sudo systemctl enable nginx
5. Access The Nginx Default Web Page

Open your browser and visit :

http://YOUR_SERVER_IP

If installation was successful, you'll see the default Welcome to Nginx page.

6. Manage Nginx (Start, Stop, Restart)

Use the following commands to control Nginx :

Start Nginx

sudo systemctl start nginx

Stop Nginx

sudo systemctl stop nginx

Restart Nginx

sudo systemctl restart nginx

Reload configuration without downtime

sudo systemctl reload nginx
7. Important Nginx Directories On Debian 13
Path Description
/etc/nginx/nginx.conf Main Nginx configuration file
/etc/nginx/sites-available/ Virtual host configuration files
/etc/nginx/sites-enabled/ Active virtual host symlinks
/var/www/html/ Default web root
/var/log/nginx/ Access & error logs

These paths follow the standard Debian Nginx structure.

8. Configure Firewall For Nginx (Optional)

If you use ufw, allow Nginx HTTP and HTTPS traffic :

sudo ufw allow 'Nginx Full'
sudo ufw reload
9. Create A Virtual Host For Your Domain

Create a new configuration file :

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

Basic configuration :

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    root /var/www/yourdomain.com;
    index index.html index.php;

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

Enable the site :

sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/

Check configuration :

sudo nginx -t

Reload Nginx :

sudo systemctl reload nginx
10. Add Free SSL Using Certbot (Optional)

Install Certbot :

sudo apt install certbot python3-certbot-nginx -y

Enable HTTPS :

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Your website will now use HTTPS automatically.

Conclusion

Installing Nginx on Debian 13 (Trixie) is simple and fast. After completing these steps, your server is ready to host websites, applications, APIs, and more. You can now proceed with setting up PHP, MariaDB, or deploying your web applications.

ahmad

Ahmad

I am just began write something this similar tips website, and hope you like it what I just began.