🖥️ 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
-
Update the package list:
-
Install Apache:
-
Start and enable Apache service:
CentOS/RHEL
-
Update the package list:
-
Install Apache:
-
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
-
Create a configuration file:
-
Ubuntu/Debian:
-
CentOS/RHEL:
-
Ubuntu/Debian:
-
Add the following content:
-
Enable the virtual host configuration:
-
Ubuntu/Debian:
-
CentOS/RHEL:
-
Ubuntu/Debian:
-
Create the Document Root:
-
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)
-
Install OpenSSL:
-
Ubuntu/Debian:
-
CentOS/RHEL:
-
Ubuntu/Debian:
-
Generate a self-signed certificate:
-
Configure SSL in the virtual host file:
-
Enable SSL module and site:
-
Ubuntu/Debian:
-
CentOS/RHEL:
-
Ubuntu/Debian:
