How to Install Apache on Debian 10

Install Apache on Debian 10

In this article, we will have explained the necessary steps to install and configure Apache on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Apache HTTP Server, also known as “Apache.” It is a web server famous for promoting the growth of the World Wide Web. Apache is the opensource, cross-platform, powerful, stable, reliable and free web server providing features which can be extended by the wide variety of modules. It is also used as a reverse proxy server in different scenarios.

Install Apache on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install Apache on Debian 10.

Apache Web server packages are available on Debian 10 official repositories. All that’s needed is execution of install command with sudo:

sudo apt install apache2

After completion of the above command, Apache is installed on your system. Run the following command to check apache service status:

sudo systemctl status apache2

Confirm Apache build and version:

# sudo apache2 -v
Server version: Apache/2.4.38 (Debian)
Server built:   2019-05-31T20:46:05

Now that you have your web server up and running, let’s go over some basic management commands:

sudo systemctl start apache2.service   ## <-- Start the server ##
sudo systemctl restart apache2.service ## <-- Restart the server ##
sudo systemctl stop apache2.service    ## <-- Stop the server ##
sudo systemctl reload apache2.service  ## <-- Reload the server config ##
sudo systemctl status apache2.service  ## <-- Get the server status ##

Following are the Apache important files and directories:

  • Apache main configuration file is located at /etc/apache2/apache2.conf
  • Apache main configuration files directory: /etc/apache2/
  • Ports where apache can listen are defined in /etc/apache2/ports.conf
  • Virtual Host files stored at /etc/apache2/sites-available and to activate each file should be linked to /etc/apache2/sites-enabled directory
  • Error log file located at /var/log/apache/error.log
  • Access log file located at /var/log/apache/access.log
  • Document root for web files /var/www/html/

Step 3. Adjust the Firewall for Apache Web Server.

It is important that you open TCP port 80 (www) and 443 (https) so that Apache on Debian 10 works. Type the following commands:

sudo ufw allow www
sudo ufw allow https
sudo ufw status

Step 4. Verify Apache Installation.

Open your favorite browser and open below URL to verify Apache installation:

http://YOUR_IP_ADDRESS-or-YOUR-DOMAIN-NAME

Congratulation, you have learned how to install and configure Apache on Debian 10 Buster. If you have any question, please leave a comment below.