• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Friday, May 23, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to set up a web server on Debian using Nginx

in Debian, Linux OS
How to set up a web server on Debian using Nginx

If you’re looking to set up a web server on Debian, Nginx is a popular choice due to its lightweight nature and efficient handling of high traffic. In this guide, we’ll walk through the steps to set up Nginx on a Debian machine and configure it to serve web content.

Step 1: Install Nginx

First, update the package manager:

sudo apt update

Then, install Nginx:

sudo apt install nginx

Step 2: Adjust Firewall Settings

Next, you’ll want to adjust your firewall settings to allow HTTP and HTTPS traffic. If you’re using ufw, you can do this with the following commands:

sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
sudo ufw enable

Step 3: Configure Nginx

By default, Nginx will serve the files located in the /var/www/html directory. If you’d like to serve content from a different directory, you’ll need to adjust the configuration file.

Open the configuration file with your preferred text editor:

sudo nano /etc/nginx/sites-available/default

Then, adjust the root setting to point to your desired directory:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /path/to/your/directory;
    index index.html;

    server_name your-domain.com www.your-domain.com;

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

Save and close the file, then test the configuration with the following command:

sudo nginx -t

If the test is successful, restart Nginx with the following command:

sudo systemctl restart nginx

Step 4: Test the Server

Finally, you’ll want to test that the server is up and running. Open a web browser and navigate to your server’s IP address or domain name. You should see the content located in the directory you specified in the configuration file.

Congratulations! You’ve successfully set up a web server on Debian using Nginx. From here, you can customize the server to your liking, add SSL certificates for secure connections, and more.

ShareTweet
Previous Post

How to set up a web server on Debian using Apache

Next Post

How to deploy and manage containerized applications on Debian with Docker and Kubernetes

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.