How Do I Setup a Web Server on Debian?


Larry Thompson

How Do I Setup a Web Server on Debian?

Setting up a web server on Debian is a straightforward process that allows you to host your own websites and applications. In this tutorial, we will walk you through the steps to get your web server up and running in no time.


Before we begin, make sure you have:

  • A Debian-based system (such as Debian itself or Ubuntu)
  • Root access or sudo privileges
  • A stable internet connection

Step 1: Update and Upgrade

The first step is to update and upgrade your system to ensure you have the latest packages and security patches. Open a terminal and run the following commands:

$ sudo apt update
$ sudo apt upgrade

This will ensure that your system is up to date.

Step 2: Install Apache Web Server

The next step is to install Apache, one of the most popular web servers available. Apache provides a robust and secure environment for hosting websites. To install Apache, run the following command:

$ sudo apt install apache2

This command will install Apache along with any required dependencies.

Start and Enable Apache

To start the Apache service, run the following command:

$ sudo systemctl start apache2

You can also enable Apache to start automatically on boot by running:

$ sudo systemctl enable apache2

This ensures that your web server will be available even after a system restart.

Step 3: Configure Firewall

By default, Debian comes with a firewall called iptables. You need to allow incoming traffic on port 80 (HTTP) and port 443 (HTTPS) to access your web server. Run the following commands to configure the firewall:

$ sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
$ sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
$ sudo iptables-save | sudo tee /etc/iptables/rules.v4

This will allow incoming HTTP and HTTPS traffic on your web server.

Step 4: Test Your Web Server

To test if your web server is running correctly, open a web browser and enter your server’s IP address or hostname. You should see the default Apache welcome page.

If you don’t know your server’s IP address, you can find it by running the following command:

$ ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Replace eth0 with the name of your network interface if necessary.


You have successfully set up a web server on Debian. Now you can start hosting your own websites and applications. Remember to secure your server and configure any additional features as per your requirements.

Thank you for reading this tutorial!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy