Install Apache on Debian 9 Server - Step by Step Process ?

Apache is an open-source and cross-platform HTTP server that powers a large number of websites. Apache web server is the most widely-used web server in the world. It also has many powerful features, dynamically loadable modules with other popular software.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Apache queries.

In this context, we shall look into how to install Apache web server on Debian 9.


How to Install Apache on Debian 9 ?

To start with this installation procedure, ensure that you use a non-root user account and make sure that you have full root access.

Apache installation is very easy because Apache is available in the default Debian repositories.

The follow the steps below to install Apache.


  • Begin with updating the package index and then will install the apache2 package using below commands :
$ sudo apt update
$ sudo apt install apache2

Here, we use sudo as command so these operations are executed with root privileges and it will prompt you to enter your regular user password to verify.

Once Apache is installed and it will start apache2 service automatically.


How to Adjust the Firewall ?

After Apache installation make sure that your firewall allows HTTP and HTTPS traffic.

i. You can check "WWW" profile enables traffic or not by typing :

$ sudo ufw app info "WWW Full"
Output
Profile: WWW Full
Title: Web Server (HTTP,HTTPS)
Description: Web Server (HTTP,HTTPS)
Ports:
   80,443/tcp

ii. Then, Allow incoming HTTP and HTTPS traffic for this profile:

$ sudo ufw allow in "WWW Full"


How to Test Apache Installation ?

You can also check Apache status by execute below command :

$ sudo systemctl status apache2

It will show you output like below :

Output
● apache2.service - The Apache HTTP Server
    Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
    Active: active (running) since Sat 2019-03-23 16:30:47 UTC; 13min ago
  Main PID: 491 (apache2)
    CGroup: /system.slice/apache2.service
            ├─ 491 /usr/sbin/apache2 -k start
            ├─1723 /usr/sbin/apache2 -k start
            └─1724 /usr/sbin/apache2 -k start

Another way to check is, open your web browser, type your server IP address or domain name http://YOUR_SERVER_IP and you will see the default Apache welcome page.


How to Manage Apache Processes ?

Now your web server is installed and up to run so we will see some basic management commands.

i. To stop Apache service you can run :

$ sudo systemctl stop apache2

ii. You can again start Apache service by type :

$ sudo systemctl start apache2

iii. To do Restart (stop and start) the Apache service:

$ sudo systemctl restart apache2

iv. If you have need to making configuration changes, Apache can reload without dropping connections. For this, use this command:

$ sudo systemctl reload apache2

v. If you want to disable the Apache service type:

$ sudo systemctl disable apache2

vi. To re-enable the service to start up at boot, type:

$ sudo systemctl enable apache2


[Need urgent assistance in fixing Apache errors? We can help you. ]

This article covers how to install an Apache web server on your Debian 9 server. The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.


How to Install Apache ?

1. Let's begin by updating the local package index to reflect the latest upstream changes:

$ sudo apt update

2. Then, install the apache2 package:

$ sudo apt install apache2

 After confirming the installation, apt will install Apache and all required dependencies.


The Apache profiles begin with WWW:

1. WWW: This profile opens only port 80 (normal, unencrypted web traffic).

2. WWW Cache: This profile opens only port 8080 (sometimes used for caching and web proxies).

3. WWW Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic).

4. WWW Secure: This profile opens only port 443 (TLS/SSL encrypted traffic).


How to Manage Apache Process ?

To stop your web server, type:

$ sudo systemctl stop apache2

To start the web server when it is stopped, type:

$ sudo systemctl start apache2

To stop and then start the service again, type:

$ sudo systemctl restart apache2

If you are simply making configuration changes, Apache can often reload without dropping connections. To do this, use this command:

$ sudo systemctl reload apache2

By default, Apache is configured to start automatically when the server boots. If this is not what you want, disable this behavior by typing:

$ sudo systemctl disable apache2

To re-enable the service to start up at boot, type:

$ sudo systemctl enable apache2

Apache should now start automatically when the server boots again.

Related Posts