Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
How to Install Wine 8 on Debian 11
Next article icon

How To Install the Apache Web Server on Debian 11?

Last Updated : 12 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Apache is an open-source web server that’s available for Linux servers free of charge. Installing an Apache web server on Linux is a straightforward process. In this article, we will install Apache Web Server Debian 11 (Bullseye).

Steps to Install Apache Web Server in Linux

Step 1: Update Your System

sudo apt update && sudo apt upgrade
updating_system
Updating system to latest packages

Step 2: Install Apache Web Server

sudo apt install apache2 -y
installing_apache
installing Apache Web Server

Step 3: Enable the Services

sudo systemctl enable apache2
enabling_system_services_for_apache
enabling system services for Apache Web Server

Step 4: Test the Server by Hosting Simple Website

First, we will create a directory for our test website using following command.

sudo mkdir /var/www/html/test_website/
  • Now we will add index.html for our test website along with some testing code using following command.
echo '
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>GFG</h1>
<p>This is a test working on Debian</p>
</body>
</html>' | sudo tee /var/www/html//index.html
  • Now we will add configuration file using following command
sudo gedit /etc/apache2/sites-available/test_website.conf 
  • and paste following config to text editor window and save it.
<VirtualHost *:80>
DocumentRoot /var/www/html/test_website
DirectoryIndex index.html
ErrorLog ${APACHE_LOG_DIR}/test_website_error.log
CustomLog ${APACHE_LOG_DIR}/test_website_access.log combined
</VirtualHost>
saving_configuratino
saving configuration
  • Once we created the required config file and test website, we will need to own the Apache website directory for permissions.
  • We will use chmod command as follows:
sudo chmod a+wr /var/www/html/ -R

Step 5: Enable the site

After creating config file, we need to enable the site. We use the a2ensite command followed by the name of site configuration file. This creates a symbolic link from the sites-available directory to the sites-enabled directory, effectively enabling the site.

syntax:

 sudo a2ensite <site_config>
sudo a2ensite test_website.conf 
  • Now we will need to restart apache2 using systemctl reload command.
sudo systemctl reload apache2
  • Now you can see locally hosted website on localhost.
http://localhost
testing_website
testing website

If the above mentioned steps performed correctly, Apache Web Server will run successfully! However, If it didn’t work, then you can uninstall Apache Web Sever and can start installation again.

Steps to Uninstall Apache Web Server

  • You can completely remove Apache Web Server using apt purge command as follows
sudo apt purge apache2 -y
  • Hence we have successfully uninstalled Apache Web Server in Debian 11!
uninstalling_Apache
Uninstalling Apache Web Server

Conclusion

In this article, we have installed and configured the Apache Web Server on Debian 11. We have outlined the fundamental steps, encompassing updating package lists, installing the software, verifying its operation, and hosting test website. So install Apache Web Server on your Linux now!


Next Article
How to Install Wine 8 on Debian 11
author
isnik
Improve
Article Tags :
  • Web Technologies
  • Apache

Similar Reads

  • How To Install the Apache Web Server on CentOS 7
    Apache Web Server, commonly known as Apache is a free, open-source, and one of the most widely used web servers in the world. Apache web server is developed and maintained by Apache Software Foundation. Apache is not any physical server, it is a software application running either on a physical/virt
    4 min read
  • How to Install Apache Web Server on Linux Cloud Server?
    Apache is an open-source web server used widely for hosting websites and web applications. It's popular on the internet and supports platforms like Linux, Windows, and macOS. Installing Apache on a Linux-based cloud server is straightforward. Cloud servers offer flexibility and scalability, enabling
    5 min read
  • How to Install Wine 8 on Debian 11
    Wine is a free program that lets you run Windows apps on your Linux computer. The Wine team released the new stable version 8.0 in January 24 2023. You can get the Wine 8 from the official website or using the package manager on your Linux system. This guide will show you how to install the Wine 8 v
    6 min read
  • How to install and configure Apache Web Server on Godaddy Server?
    GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. It’s a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache HTTP Server is an open-source web server softw
    2 min read
  • How to Install mod_ssl on RHEL/CentOS 7 with Apache Web Server?
    Strong cryptography comes to the Apache HTTP Server via the mod_ssl module with Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. Enabling SSL on your Apache web server enhances security by encrypting the data between the server and clients. There are several methods to instal
    3 min read
  • How to Install Apache Web Server in Linux: Ubuntu, Fedora, RHEL?
    If you're looking to install Apache on Linux, this guide will walk you through the steps required for different distributions, including Ubuntu, Fedora, and RHEL. The Apache web server is a popular choice for hosting websites and applications, known for its reliability and flexibility. Whether you'r
    5 min read
  • How to Install and Customize Apache on Ubuntu or Debian?
    One of the most dominant forces in web server software is the Apache HTTP Server, often shortened to Apache. This free and open-source project, overseen by the Apache Software Foundation, has been a major player in shaping the Internet since its launch in 1995. Installing an Apache web server on Ubu
    2 min read
  • How to install and configure Apache Tomcat 10 on Godaddy Server?
    GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. It’s a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache Tomcat is a cross-platform HTTP web server tha
    3 min read
  • How to Install and Set up a WAMP Server ?
    Windows, Apache, MySQL and PHP is commonly abbreviated as WAMP. Some people may confuse with LAMP but the only difference between the two is their operating systems. In case of LAMP, L stands for Linux. Setting up a server included the installation of all the software listed in the abbreviation. Ano
    3 min read
  • How to Install Redis on Debian?
    Want to set up Redis on a Debian system? Redis is a potent in-memory data structure store that may be used as a message broker, database, and cache. We'll lead you through the Redis installation process on Debian in this article, ensuring that you can swiftly start the Redis server. Regardless of wh
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences