How to Install Apache Web Server on Debian 10 Linux
Updated on
•6 min read

Apache HTTP server is one of the most popular web servers in the world. It is an open-source and cross-platform HTTP server that powers a large percentage of the Internet’s websites. Apache provides many powerful features that can be extended through additional modules.
In this tutorial, we’ll explain how to install Apache on Debian 10, Buster.
Prerequisites
Before starting with the tutorial, make sure you are logged in as a user with sudo privileges .
Installing Apache
Apache packages are available in the default Debian repositories.
The installation is pretty straightforward. Update the package index and install the Apache web server with the following commands:
sudo apt updatesudo apt install apache2
That’s it, Apache is installed and automatically started. To check the status type:
sudo systemctl status apache2● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: 
   Active: active (running) since Sat 2019-07-27 13:55:49 PDT; 21s ago
   ...
Adjust the Firewall
UFW users can open HTTP (80) and HTTPS (443) ports by enabling the ‘Nginx Full’ profile:
sudo ufw allow 'Apache Full'If you are using nftables to filter connections to your system, open the necessary ports by issuing the following command:
nft add rule inet filter input tcp dport {80, 443} ct state new,established counter acceptVerifying Apache Installation
To verify that Apache works correctly, open your browser
, type your server IP address or domain name http://YOUR_IP_OR_DOMAIN/, and you will see the default Apache welcome page as shown below:

The page contains basic information about Apache configuration files, helper scripts, and directory locations.
Apache Configuration File’s Structure and Best Practices
- In Debian based systems Apache configuration files are located in the 
/etc/apache2directory. - The main Apache configuration file is 
/etc/apache2/apache2.conf. - The ports that Apache will listen to are specified in the 
/etc/apache2/ports.conffile. - Apache Virtual Hosts files are located in the 
/etc/apache2/sites-availabledirectory. The configuration files found in this directory are not used by Apache unless they are linked to the/etc/apache2/sites-enableddirectory. - You can activate a virtual host directive by creating a symlink
using the 
a2ensitecommand from the configuration files found in thesites-availabledirectory to thesites-enableddirectory. To deactivate a virtual host use thea2dissitecommand. - It is highly recommended to follow the standard naming convention, for example, if your domain name is 
mydomain.comthen the domain configuration file should be named/etc/apache2/sites-available/mydomain.com.conf - Configuration files that are used for loading various Apache modules are located in the 
/etc/apache2/mods-availabledirectory. Configurations in themods-availabledirectory can be enabled by creating a symlink to the/etc/apache2/mods-enabledirectory using thea2enconfcommand and disabled with thea2disconfcommand. - Files containing global configuration fragments are stored in the 
/etc/apache2/conf-availabledirectory. Files in theconf-availabledirectory can be enabled by creating a symlink to the/etc/apache2/conf-enabledusing thea2enconfcommand and disabled with thea2disconfcommand. - Apache log files (
access.loganderror.log) are located in the/var/log/apachedirectory. It is recommended to use differentaccessanderrorlog files for each virtual host. - You can set your domain document root directory to any location you want. The most common locations for webroot include:
/home/<user_name>/<site_name>/var/www/<site_name>/var/www/html/<site_name>/opt/<site_name>
 
Conclusion
Installing Apache on Debian is a matter of running a single command.
You can now start deploying your applications and use Apache as a web or proxy server.
If you have any questions or feedback, feel free to leave a comment.
This post is a part of the How to Install LAMP Stack on Debian 10 series.
Other posts in this series:


