How to Install Apache Web Server on Debian 12 Linux

To host the websites and ensure their content loads effectively, a web server is an important thing. Apache is a web server and popular because of its stability. Apache is one of the most chosen web servers by web developers all around the world. 

This post explains the Apache web server installation method on Debian 12 using the command line. 

What is the Apache Web Server Installation Method for Debian 12?

Use the following instructions to install the Apache Web server on Debian 12.

Step 1: Update the Debian 12

Update all the packages of Debian to ensure the updated package of Apache should be installed:

$ sudo apt update
Install Apache Web Server on Debian 12 Linux 1

Step 2: Install the Apache on Debian 12

To install the Apache2, run the below-mentioned command:

$ sudo apt install apache2 -y
Install Apache Web Server on Debian 12 Linux 2

Step 3: Verify the Installation of Apache 

To verify the installation with the execution of the above command, display the status of the Apache web server:

$ sudo systemctl status apache2
Install Apache Web Server on Debian 12 Linux 3

If the server is not running, then start the Apache web server using the command:

$ sudo systemctl start apache2
Install Apache Web Server on Debian 12 Linux 4

To stop the Apache web server, run the command:

$ sudo systemctl stop apache2
Install Apache Web Server on Debian 12 Linux 5

For restarting the Apache web server, execute the command:

$ sudo systemctl restart apache2
Install Apache Web Server on Debian 12 Linux 6

Another way to validate the installation of Apache, open the web browser and navigate to the “localhost” in the URL address bar:

Install Apache Web Server on Debian 12 Linux 7

How can Apache Web Server be Tested on Debian 12?

To test Apache, a web page will be created with the help of the PHP programming language. To create the web page, open the nano text editor (Text editor other than nano can also be used):

$ sudo nano /var/www/html/itslinuxfoss.php
Install Apache Web Server on Debian 12 Linux 8

Then write the PHP script to create a welcome note:

<?php
echo "Welcome to the ItsLinuxFoss”;
?>
Install Apache Web Server on Debian 12 Linux 9

Close the nano text editor by saving the file with the help of the CTRL+S. Finally, open the web browser and go to the below-mentioned URL address:

http://localhost/itslinuxfoss.php
Install Apache Web Server on Debian 12 Linux 10

A welcome note has been displayed which is authentication of the working of the Apache web server. 

How does Apache Web Server Can be Uninstall on Debian 12?

To uninstall the Apache Web server on Debian 12, use the “remove” option of the apt package manager:

Install Apache Web Server on Debian 12 Linux 11

Now remove all the files associated with the Apache web server with the execution of the command:

$ sudo apt autoremove -y
Install Apache Web Server on Debian 12 Linux 12

This is all about the installation and uninstallation of the Apache Web server on Debian 12. 

Conclusion

For the installation of the Apache web server on Debian 12, run the command “sudo apt install apache2 -y” in the command line terminal. After installation of the Apache web server, it can be managed by using the systemctl command utility. In this post, the installation method of the Apache web server on Debian 12 has been explained. Also, the testing of the Apache web server has been performed by creating the PHP script and hosting it with Apache.