When we are thinking about web server the first name is coming Apache HTTP server, it is most popular in the world for hosting any type of web applications or websites. The most important thing about Apache web server is, it is free and open-source web server and providing a powerful feature for your web application, including support of cross-platform.
In this tutorial, we will explain the process of installing the Apache webserver on Debian 8 Operating System.
To perform Apache web server installation on your Debian 8 Linux system, you should have user access to login on system and need sudo privileges to execute administrative commands to install applications.
The apache web server packages are inbuilt in Debian repository packages which we can easily install using “apt” command. The only thing is to know the Apache HTTP server’s service is known as “apache2” in Debian Operating System.
To install Apache2 package, first, need to update Debian package index and install apache2 using the following command:
$ sudo apt update
$ sudo apt install apache2
Now, the apache web server is installed and automatically started on your Debian machine. You can check the apache web server’s service status using the following command:
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-06-24 02:17:57 PDT; 2min 41s ago
Main PID: 4243 (apache2)
Tasks: 55 (limit: 2321)
|-4243 /usr/sbin/apache2 -k start
|-4244 /usr/sbin/apache2 -k start
`-4245 /usr/sbin/apache2 -k start
Configure the Firewall for Apache wen server on Debian 8
Nowadays, every system we protesting with Firewall to secure system and services. If Firewall also protests your Debian system, you need to open HTTP (80) and HTTPS (443) port to access the webserver.
Assuming your system is secured using UFW firewall, as most of the Debian machine using UFW firewall, you can open the Apache ports using the following command:
$ sudo ufw allow 'Apache Full'
You can verify the port is open or not on UFW firewall using below command:
$ sudo ufw status
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
Apache Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Apache Full (v6) ALLOW Anywhere (v6)
Verify Apache Installation
To verify apache web server installed adequately and everything working as per the instructions, open the web browser and open your web server by typing your configured domain or IP for this Debian server like “http://<your_domain_or_IP>.
If everything is working and apache webserver running fine, you will get the default Debian 8 Apache2 welcome page as shown below:
This page includes some of the necessary information about apache2 web server, configuration file, directory locations and helper scripts.
Apache Configuration File’s Structure
The Apache2 configuration file’s default location is “/etc/apache2/” directory.
The main Apache2 web server configuration file is “/etc/apache2/apache2.conf”.
The Apache listener ports configuration file located at “/etc/apache2/ports.conf”.
The virtual host files configured on Apache webserver stored in the “/etc/apace2/sites-available/” directory. But the configuration file found in this directory is not used by apache unless they linked to the “/etc/apache2/sites-enabled/” directory.
To activate the virtual host file and use it with apache configuration need to create a symlink file from “sites-available” to sites-enabled”. In apache, it is straightforward which can do by using the “a2ensite” command and similarly deactivate the virtual host file or remove symlink file use the command “a2dissite”.
To configure a virtual host file, it is good to follow the standard naming convention. For example, you are configuring virtual host for your domain “testsite.com” then you should keep the virtual host configuration name as “/etc/apache2/sites-available/testsite.com.conf”.
The apache web server’s module configuration files stored in the “/etc/apache2/mods-available/” directory. Similar to “sites-available”, “mods-available” files are usable only when it enabled by creating a symlink to the “/etc/apache2/mods-enabled/” directory using “a2enmod” command, and it disabled by using “a2dismod” command.
The global configuration files for apache web servers stored in the “/etc/apache2/conf-available/” directory. Similar to “sites-available” and “mods-available”, “conf-available” files are usable only when it enabled by creating a symlink to the “/etc/apache2/conf-enabled/” directory using “a2enconf” command, and it disabled by using “a2disconf” command.
To troubleshoot or debug the issue with the apache web server, use the log file for apache server and virtual host. The log file for apache located at “/var/log/apache2/access.log” and “/var/log/apache2/error.log”. To make it easy to troubleshoot an issue with different virtual host need to create different access and error log for each virtual host.
There is no location boundary to create document root directory, you can create at any location but as per suggestion, the most common location for webroot directory is:
You have learned to install Apache web server on your Debian 8 server or system. Now your system is ready to deploy a web application using Apache virtual host or use Apache as a web proxy server for your application.
Do you have any doubt, questions or feedback? Feel free to leave a comment.
MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...
Nowadays, a Firewall is an essential utility and property of any system for security; by default Debian Operating system having a firewall configuration tool named UFW (Uncomplicated Firewall). UFW is a user-friendly front-end tool to manage iptables firewall rules....
Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it is the language behind the ultimate robust framework known as Ruby on Rails. In this tutorial, we will explain the three...