How To Install the Apache Web Server on Debian 11

How To Install the Apache Web Server on Debian 11

·

4 min read

Apache is a free and open-source HTTP web server that is the go-to choice for people looking to host a website on the internet.

The Apache server is cross-platform, efficient, and is also extensible through its tons of loadable modules.

In this straightforward guide, I will show you exactly how to install the Apache web server on your Debian 11 distro.

You’re going to get step-by-step instructions to make sure your Apache web server is up and running in no time. So, if you’re ready to start, let’s dive right in…

# Prerequisites

Nothing over-the-top, just make sure your Linux distro is Debian based and you're logged in as a non-root user with sudo privileges.

# Installing Apache

The Apache packages are present in the Debian software repositories by default, making it easy to install without dropping a sweat.

First, open the terminal and update your system package index with the following command:

$ sudo apt update

After this process is done, run the below command to install Apache2:

$ sudo apt install apache2

You can further verify if apache2 is installed by running this command:

$ sudo systemctl status apache2

It’s going to output something similar to the response below:

$ sudo systemctl status apache2

○ apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; disabled; preset: disabl>
     Active: inactive (dead)
       Docs: https://httpd.apache.org/docs/2.4/

This shows that the Apache HTTP web server is installed on your computer but is currently inactive, but we’re going to fix this in the next section.

# Start & Test Apache

To make the Apache service start running and verify its successful installation, simply run the command below:

$ sudo systemctl start apache2

It’s going to output something like the below:

$ sudo systemctl status apache2

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; disabled; preset: dis>
     Active: active (running) since Sun 2023-03-26 11:11:49 WAT; 9s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3547 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SU>
   Main PID: 3570 (apache2)
      Tasks: 7 (limit: 4448)
     Memory: 19.0M
        CPU: 548ms
     CGroup: /system.slice/apache2.service
             ├─3570 /usr/sbin/apache2 -k start
             ├─3578 /usr/sbin/apache2 -k start
             ├─3579 /usr/sbin/apache2 -k start
             ├─3580 /usr/sbin/apache2 -k start
             ├─3581 /usr/sbin/apache2 -k start
             ├─3582 /usr/sbin/apache2 -k start
             └─3583 /usr/sbin/apache2 -k start

Mar 26 11:11:48 kali systemd[1]: Starting apache2.service - The Apache HTTP Ser>
Mar 26 11:11:49 kali apachectl[3569]: AH00558: apache2: Could not reliably dete>
Mar 26 11:11:49 kali systemd[1]: Started apache2.service - The Apache HTTP Serv>

If this is your output, then consider the apache2 service to be working on your device. Now open up a browser, type your IP address and you should see the Apache default welcome page just like the image below:

apache default welcome page on debian linux

If you’re not seeing this, make sure to check that the installation was successful and that you’re typing in the right IP address. You can run ifconfig to check your IP or Loopback IP if you’re not connected to the internet.

# Apache Process Management

When running Apache on a Linux-based system, it is important to understand how to manage the Apache process. This includes knowing how to start, stop, restart, and check the status of the Apache web server.

  • To start Apache, use the command sudo systemctl start apache2.

  • To stop the web server, use the command sudo systemctl stop apache2.

  • To restart Apache, use the command sudo systemctl restart apache2.

  • To check the status of Apache, use the command sudo systemctl status apache2.

By understanding how to manage the Apache process, it is possible to ensure that your web server is running correctly and securely.

# Conclusion

Congratulations! You have now successfully installed the Apache web server on your Debian 11 system. The Apache web server is a powerful and versatile tool for serving web content.

It can be used to host static websites, serve dynamic web applications, or act as a reverse proxy for other web services.

With its wide array of features, Apache makes it possible to create custom web solutions that can meet the needs of almost any website or application

I hope this tutorial was helpful in getting you started with Apache on Debian 11 Linux. Thank you for reading!

Kindly leave a comment if you run into any errors or leave a like, perhaps share, the article if you’re able to get it running successfully.