In this opportunity we wanted to bring you a complete and detailed post about how to install an Apache web server on Debian, specifically in the Debian version. ENTERS!
Before getting into the subject, it is important to remember that Apache, more specifically Apache HTTP Server, it is a secure, extensible and highly efficient open source web server; Being the world's most used web server.
This server offers a functionality capable of meeting all the requirements defined by the current HTTP protocol standards. Among its most powerful features are that:
- Includes modules that load dynamically;
- Media compatibility;
- Wide integration with other software tools;
- Among other.
Requirements to install an Apache web server on Debian
- For the respective installation it is necessary to have the Linux Debian operating system installed and updated.
- Have an Internet connection.
- Have a normal non-root user with sudo privileges configured on your server. Once you have an account, you must log in as a non-root user to start.
- Enable a basic Firewall that does blocking non-essential ports.
Steps to install an Apache web server on Debian
Next, we will list the steps necessary to perform this installation, follow each instruction below.
The apache server it is available from the Debian software repositories; so its installation can be carried out using package management tools.
Now, first, the local packages index must be updated by entering in the terminal:
sudo apt update
Later if you can install apache2 package:
sudo apt install apache2
Upon confirming the installation, apt will install Apache.
Configure the Firewall
Prior to use apache must be modify Firewall settings so that it allows access external to the default web ports.
By following the instructions when you activated the Firewall, you should have a UFW Firewall whose configuration restricts access to your server.
With the apache installation, this is registered with UFW in order to provide some application profiles that can be deployed to enable or disable access to the web server through the Firewall.
To view the UFW application profiles type:
sudo ufw app list
The following list will be displayed:
Output Available applications: AIM Bonjour CIFS. . . WWW WWW Cache WWW Full WWW Secure. . .
The Apache profiles are as follows:
- WWW: it only opens port 80, that is, normal unencrypted web traffic.
- WWW Cache: it opens only port 8080, which is sometimes used for cache and web proxies.
- WWW Full: opens port 80 (normal unencrypted web traffic) and port 443 (encrypted TLS / SSL traffic).
In this case, you should only allow the traffic on port 80, as SSL traffic has not been configured for the server yet. Write the following:
sudo ufw allow 'WWW'
and to verify the changes write:
sudo ufw status
It should show the allowed HTTP traffic:
Output Status: active To Action From - ----- --- OpenSSH ALLOW Anywhere WWW ALLOW Anywhere Open SSH (v6) ALLOW Anywhere (v6) WWW (v6) ALLOW Anywhere (v6)
As you can see, the WWW profile was activated to allow access to the server.
Check the web server
Once the Apache installation process on Debian completes, it starts automatically and you should be up and running.
However, for verify that the service is runningor write the following:
sudo systemctl status apache2
Output Apache2.service - The Apache HTTP Server Loaded: loaded (/lib/system/system/apache2.service.service; enabled; vendor preset: enable) Active: active (running) since Wed 2020-03-31 19:21: 48 UTC; 13min ago Main PID: 12849 (apache2) CGroup: /system.slice/apache2.service ├─12849 / usr / sbin / apache2 –k start ├─12850 / usr / sbin / apache2 –k start └─12852 / usr / sbin / apache2 –k start Mar 31 19:21:48 apache system : Starting The Apache HTTP Server ... Mar 31 19:21:48 apache systemd : Started The Apache HTTP Server.
You can notice that the service started successfully. Although, to be completely sure it is recommended to request a page from Apache.
To do this, you can go to Apache's default landing page to confirm that the software works fine using its IP address.
Use the curl tool to get public IP address. Install curl using apt:
sudo apt install curl
Then if you can use curl to recover icanhazip.com using IPv4:
curl -4 icanhazip.com
Once you obtain the IP address of the server, enter it in the address bar of the browser and enter your IP.
The default Apache web page from Debian 9 should be displayed
Manage the Apache process
What this step consists of is going over some basic administration commands. For example:
For stop server:
sudo systemctl stop apache2
Start the server when it has stopped:
sudo systemctl start apache2
Stop then start the service again:
sudo systemctl restart apache2
In case of just make configuration changesApache usually reloads without closing connections. To do this, type the following:
sudo systemctl reload apache2
By default, Apache is configured to start automatically when the server does. In case you don't want this to happen, you can disable it typing the following:
sudo systemctl disable apache2
For reverse that action, you must write:
sudo systemctl enable apache2
So Apacha should start automatically when the server does it again.
The next step is to familiarize yourself with the important Apache files and addresses, including the server configuration, but we'll talk about that in a future post.
For now we recommend another of our post:
We say goodbye until the next opportunity.