How to Install Apache Web Server on Debian 11 Tutorial (Step by Step)

How to Install Apache Web Server on Debian 11 (Tutorial). In this article we will introduce what Apache web server is with its pros and begin installation tutorial on Debian 11.

What is Apache

Apache is a free and open source web server developed by the Apache Software Foundation to deliver web content through the internet. It got released initially with a goal to sync HTTP services with the current HTTP standards. However, today it is compatible with major operating systems and used to provide web content to users through the internet. It is not any physical server, but software that responds to client needs and transfers requested files.

When a visitor opens the website and tries to load other pages like the “About Us” or “contact us” page, the visitor’s web browser immediately passes on the request to the servers. In return, Apache responds with the requested file. Both the client and server use the HTTP protocol to communicate and transfer files.

Apache HTTP server is one of the oldest go to web servers that has gained a lot of popularity over the years. Most enterprises trust Apache web servers as it helps create a secure connection between servers and web browsers to transfer web content. It is one of the popular web servers with many advanced features like load balancing, bandwidth throttling, session tracking, server side scripting, auto indexing, an authentication mechanism, Gzip compression and decompression, etc.

One of the advantages of choosing Apache is it can handle heavy traffic with minimal configuration. It is an easy to install, configure and is scalable web server compatible with multiple programming languages.

Apache also supports numerous modules: 



mod_noloris, mod_limitipconn, mod_evasive

and mod_qos


for caching, password authentication, URL rewriting, security, and other purposes.

This web server offers speed, security and excellent performance. It is highly trustworthy and available for free for both personal and business purposes. Comparing other popular web servers like NGINX, IIS, LiteSpeed, etc., Apache still ranks high and dominates the market share by 33% across all websites.

Users or enterprises have to no longer worry about the security risks as it offers a secure environment to host a website. Also, it supports various CMS, including WordPress, Joomla, Weebly, Drupal, etc.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Benefits of Apache Web Server

Investing time and money into Apache web servers is a great call for enterprises. If your enterprise wishes to run its website or application on a stable platform, look no further. Apache web server is one of the oldest and most secure web servers with advanced features and allows handling heavy traffic. Here are a few benefits of using an Apache webserver:

  • Apache Web Server is a free, reliable, open source server customizable and available even for commercial use.
  • It provides updated security patches frequently and on a regular basis to improve performance and minimize security vulnerabilities.
  • Apache Web Server is easy to configure and highly flexible
  • It supports a huge community and available 24*7 for support
  • The software is compatible with multiple platforms and supports various programming languages, including Python, PHP, etc.
  • It supports CMS such as WordPress websites and Joomla
  • Users have access to view and modify the code as it is open source
  • It allows access to add macros and addons
  • All changes can be saved without the need to restart
  • Allows to host multiple websites simultaneously
  • All documentation and tutorials are updated regularly for guidance
  • Faces less static and dynamic issues
  • It has a flexible module based structure that supports features like URL rewriting, HTTP/2 and FTP connections, auto indexing, and more.
  • Apache provides features like SSL certificate and CGL for better security
  • It is one of the fastest and most secure web server software compatible with IPv6

Follow this this post below to show you how to install the Apache web server on Debian 11.

How to Install Apache Web Server on Debian 1

Install Apache

By default, the Apache webserver is included in the most Linux based operating system. You can install it by just running the following command:

					apt-get install apache2 -y

The above command will install the Apache webserver to your system and starts the Apache service automatically. You can check the Apache listening port using the following command:

					ss -antpl | grep 80

You will get the following output:

					LISTEN   0         511                       *:80                     *:*        users:(("apache2",pid=3454,fd=4),("apache2",pid=3453,fd=4),("apache2",pid=3452,fd=4))


Now, open your web browser and access the Apache test page using the URL http://your-server-ip. You should see the Apache test page in the following screen:

Manage Apache Service Using Systemd

At this point, the Apache webserver is up and running. You can manage the Apache service using the systemctl command line utility.

To stop the Apache service, run the following command:

					systemctl stop apache2

To restart the Apache service, run the following command:

					systemctl restart apache2

To enable the Apache service to start at system reboot, run the following command:

					systemctl enable apache2

To verify the status of the Apache service, run the following command:

					systemctl status apache2

You will get the following output:

					● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-03-29 14:57:04 UTC; 8s ago
    Process: 12003 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 12007 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 19.9M
        CPU: 104ms
     CGroup: /system.slice/apache2.service
             ├─12007 /usr/sbin/apache2 -k start
             ├─12008 /usr/sbin/apache2 -k start
             ├─12009 /usr/sbin/apache2 -k start
             ├─12010 /usr/sbin/apache2 -k start
             ├─12011 /usr/sbin/apache2 -k start
             └─12012 /usr/sbin/apache2 -k start

March 29 14:57:04 Debian11 systemd[1]: Starting The Apache HTTP Server...

Apache Virtual Hosting

Apache provides virtual hosting feature that allow you to host multiple websites on a single server. In this section, we will host a new website using the domain name

Create a Website Directory

First, you will need to create a directory for your new website:

					mkdir /var/www/html/

Next, change the ownership of your website directory to www-data:

					chown -R www-data:www-data /var/www/html/

Then set proper permission to the website directory.

					chmod -R 755 /var/www/html/

Following that create an Index.html page inside your website directory:

					nano /var/www/html/

Add the following code:

        <p>Welcome to Apache Web Server!</p>
        <h3>Success!  The virtual host is working!</h3>
    <script>class RocketElementorAnimation{constructor(){this.deviceMode=document.createElement("span"),"elementor-device-mode",this.deviceMode.setAttribute("class","elementor-screen-only"),document.body.appendChild(this.deviceMode)}_detectAnimations(){let t=getComputedStyle(this.deviceMode,":after").content.replace(/"/g,"");this.animationSettingKeys=this._listAnimationSettingsKeys(t),document.querySelectorAll(".elementor-invisible[data-settings]").forEach(t=>{const e=t.getBoundingClientRect();if(e.bottom>=0&&<=window.innerHeight)try{this._animateElement(t)}catch(t){}})}_animateElement(t){const e=JSON.parse(t.dataset.settings),i=e._animation_delay||e.animation_delay||0,n=e[this.animationSettingKeys.find(t=>e[t])];if("none"===n)return void t.classList.remove("elementor-invisible");t.classList.remove(n),this.currentAnimation&&t.classList.remove(this.currentAnimation),this.currentAnimation=n;let s=setTimeout(()=>{t.classList.remove("elementor-invisible"),t.classList.add("animated",n),this._removeAnimationSettings(t,e)},i);window.addEventListener("rocket-startLoading",function(){clearTimeout(s)})}_listAnimationSettingsKeys(t="mobile"){const e=[""];switch(t){case"mobile":e.unshift("_mobile");case"tablet":e.unshift("_tablet");case"desktop":e.unshift("_desktop")}const i=[];return["animation","_animation"].forEach(t=>{e.forEach(e=>{i.push(t+e)})}),i}_removeAnimationSettings(t,e){this._listAnimationSettingsKeys().forEach(t=>delete e[t]),t.dataset.settings=JSON.stringify(e)}static run(){const t=new RocketElementorAnimation;requestAnimationFrame(t._detectAnimations.bind(t))}}document.addEventListener("DOMContentLoaded",;</script></body>

Save and close the file when you are finished.

Configure Apache to Host Website

Next, you will need to create an Apache virtual host configuration file to serve the index.html located inside directory.

You can create it with the following command:

					nano /etc/apache2/sites-available/domain.conf

Add the following configuration:

					<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Save and close the file then activate the Apache virtual host with the following command:

					a2ensite domain.conf

Next, restart the Apache service to apply the configuration changes:

					systemctl restart apache2

Test Apache Web Sever

At this point, the Apache web server is configured to serve the index.html page via domain. You can now test it using the URL in your web browser. If everything is fine, you should see the following page:

How to Install Apache Web Server on Debian 11 Conclusion

In this post, you learned how to install the Apache webserver on Debian 11. You also learned how to use virtual hosting to host a website on the internet. I hope you can now host multiple websites on a single server using Apache webserver.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x