Apache, also known as Apache HTTP server, has been one of the most widely used web server applications globally for the past few decades. By default, Apache is installed, and on Debian 11 Bullseye repository; however, with Debian, stable versions do not change for the most part except for security or urgent bug updates to keep the title “stable,” which they are known. Due to this, Apache can miss out on new features and improvements and non-security-related bug fixes especially given the time delay between stable Debian releases being a few years in between.
In the following tutorial, you will learn how to Upgrade to the latest Apache web server on Debian 11 Bullseye.
Table of Contents
- Recommended OS: Debian 11 Bullseye
- User account: A user account with sudo privilages or root access (su command).
- Required Packages: curl
Updating Operating System
Update your Debian 11 operating system to make sure all existing packages are up to date:
sudo apt update && sudo apt upgrade
Root or Sudo Access
By default, when you create your account at startup with Debian compared to other distributions, it does not automatically receive sudoers status. You must either have access to the root password to use the su command or visit our tutorial on How to Add a User to Sudoers on Debian.
Install CURL Package
The tutorial will utilize the curl package; first, verify if the package is present:
Example output if installed:
curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3 Release-Date: 2020-12-09
If you do not have curl installed, use the following command:
sudo apt install curl -y
Install Latest Apache
Adding Apache Repository by Ondřej Surý Repository
The first step is to import and install the Apache webserver to the latest version is add the repository by Ondřej Surý’s. For those unfamiliar, Ondřej is the maintainer for PHP on Debian.
To add the Repository, use the following command in your terminal:
curl -sSL https://packages.sury.org/apache2/README.txt | sudo bash -x
Update your repository to reflect the new change:
sudo apt update
Now that you have installed the Apache repository and updated the repository list, install Apache2 with the following:
sudo apt install apache2
Type Y, then press the enter key to proceed and complete the installation.
Next, confirm the installation was successful by confirming the new build:
sudo apache2 -v
Server version: Apache/2.4.51 (Debian) Server built: 2021-10-07T19:28:50
Now, make sure Apache is running by using the systemctl command:
systemctl status apache2
If Apache is not activated, to start the webserver application, use the following command:
sudo systemctl start apache2
To enable Apache on system boot, use the following:
sudo systemctl enable apache2
Example output if successful:
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable apache2
This version will always be maintained and updated when a new version of Apache is available; Ondřej Surý updates typically within a few days to a few weeks as he maintains PHP, Nginx, and Apache repositories built; he is consistent with his updating.
Optional. Configure UFW Firewall for Apache
After installing Apache 2 web server, you will need to modify the UFW rules if you have UFW installed. To allow outside access to the default web ports. Luckily, during the installation, Apache registers itself with UFW to provide a few profiles that can be used to enable or disable access, making it easy and quick to configure.
If you would like to install the UFW firewall, run the following command:
sudo apt install ufw -y
Once UFW is installed, enable UFW to start and be active on system boot.
sudo ufw enable
Next, list the application profiles to see the Apache profiles that are available by the following command:
sudo ufw app list
Available applications: Apache Apache Full Apache Secure
From the output above, you have three profile options to choose from. To break it down, Apache runs on port 80 (HTTP), Apache Secure runs on port 443 (HTTPS), and Apache Full is a combination of allowing both. The most common is either Apache Full or Apache Secure.
For the tutorial, since we have not set up SSL, we will enable (Apache) profile with the following command:
sudo ufw allow 'Apache'
Rule added Rule added (v6)
As above, the rules have been added for both IPV4 and IPV6. Later on, you can disable this profile and enable secure only or disable the Apache rule and use the Apache Full rule instead.
How to Keep Apache Updated
To update Apache in the future, all you need to do is run the apt update command as the new repository is added to the apt source list:
sudo apt update
If one is available, upgrade Apache as follows:
sudo apt upgrade
Or upgrade Apache by itself:
sudo apt upgrade apache2
That is all you need to do to keep your version updated.
Comments and Conclusion
In the tutorial, you have learned how to install Apache 2 either using the repository by Ondřej Surý. Overall, Apache has been the most used web application server in the World for decades. However, Nginx has finally overtaken the lead just slightly. Apache is still one of the most deployed and recognized web applications, especially with combing LAMP stack, which is often used for back-end web servers. You will find more friendly options for Apache than Nginx, leading newer users to get into hosting their web server, perhaps to try Apache over Nginx as the first step.