Skip to main content

🖥️ Apache HTTP Server (httpd) Documentation

🌟 Overview

Apache HTTP Server, commonly referred to as Apache or httpd, is an open-source web server software that is highly customizable and widely used. It can serve static content, dynamic web pages, and integrate with various modules to extend its capabilities.

📦 Installation

Ubuntu/Debian

  1. Update the package list:
  2. Install Apache:
  3. Start and enable Apache service:

CentOS/RHEL

  1. Update the package list:
  2. Install Apache:
  3. Start and enable Apache service:

🔧 Basic Configuration

Main Configuration File

  • Location: /etc/apache2/apache2.conf (Ubuntu/Debian), /etc/httpd/conf/httpd.conf (CentOS/RHEL)

Virtual Hosts

Virtual hosts allow you to run multiple websites on a single server.

Sample Configuration

  1. Create a configuration file:
    • Ubuntu/Debian:
    • CentOS/RHEL:
  2. Add the following content:
  3. Enable the virtual host configuration:
    • Ubuntu/Debian:
    • CentOS/RHEL:
  4. Create the Document Root:
  5. Add a sample index file:

🛠️ Common Commands

Managing Apache Service

  • Start Apache:
  • Stop Apache:
  • Restart Apache:
  • Reload Apache (for configuration changes):
  • Check Apache status:

Enable/Disable Modules (Ubuntu/Debian)

  • Enable a module:
  • Disable a module:

Logs

  • Access log: /var/log/apache2/access.log (Ubuntu/Debian), /var/log/httpd/access_log (CentOS/RHEL)
  • Error log: /var/log/apache2/error.log (Ubuntu/Debian), /var/log/httpd/error_log (CentOS/RHEL)

🔍 Additional Configuration

Enabling SSL (HTTPS)

  1. Install OpenSSL:
    • Ubuntu/Debian:
    • CentOS/RHEL:
  2. Generate a self-signed certificate:
  3. Configure SSL in the virtual host file:
  4. Enable SSL module and site:
    • Ubuntu/Debian:
    • CentOS/RHEL:

🏁 Conclusion

Apache HTTP Server is a versatile and powerful tool for serving web content. By following this guide, you can set up and configure Apache on your system, create virtual hosts, and enable SSL for secure communication. Use the commands provided to manage your Apache server effectively.