Nginx is a popular high-performance web server and reverse proxy server, not only extremely fast at handling static content but also offers advanced features such as load balancing, caching, and more, making it a very powerful tool for modern web application architectures. Setting up a Nginx server on Debian 11 Bullseye is a simple and straightforward process, and this article will guide you through each step.

Step 1: System Update

Before you begin the installation, you need to make sure your system is up to date. This step is crucial as it ensures the security and stability of your system. Open a terminal and execute the following commands:

sudo apt update
sudo apt upgrade
sudo apt install curl gnupg2 ca-certificates lsb-release

This will update the list of software, upgrade all installed packages, and install some dependencies that might be needed during the Debian 11 Nginx installation process.

Step 2: Install Nginx

Installing Nginx only requires a single command. Enter the following command in the terminal to install Nginx:

sudo apt install nginx

The system will automatically handle the dependencies and will offer a series of additional packages that are recommended. Once the installation is complete, Nginx will be added as a service to your system.

Step 3: Start and Configure the Nginx Server

After Nginx is installed, you need to start it and set it to start at boot:

sudo systemctl start nginx
sudo systemctl enable nginx

These commands will start the Nginx service and ensure that Nginx starts automatically after the system reboots.

Step 4: Verify Nginx Installation

To verify that Nginx has been installed correctly, you can check its version:

nginx -v

If the Nginx version information is displayed, it means that Nginx has been successfully installed.

Step 5: Configure the Firewall

Now you need to configure the firewall to allow HTTP and HTTPS traffic. Debian uses ufw as its firewall management tool. Run the following commands to allow web traffic:

sudo ufw allow 'Nginx HTTP'

If you also want to enable HTTPS, you need to run:

sudo ufw allow 'Nginx HTTPS'

Step 6: Test Nginx in a Web Browser

Open your web browser and enter your server’s IP address:

http://your-server-ip-address

If the installation was successful, you should see the default Nginx welcome page.

Next Steps and Resources

After installation, you may need to perform further configuration to meet your specific needs. The Nginx official website provides an abundance of documentation to help you understand how to configure server blocks, set up SSL/TLS, and perform performance tuning, among other things.