Linux Apache Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux Apache Guide
Complete beginner-friendly guide to Apache HTTP Server on Linux, covering Arch Linux, CachyOS, and other distributions including installation, configuration, and virtual hosts.
Table of Contents
Apache Installation
Install Apache
Arch/CachyOS:
# Install Apache
sudo pacman -S apache
# Enable service
sudo systemctl enable --now httpd
# Check status
systemctl status httpd
Debian/Ubuntu:
sudo apt install apache2
sudo systemctl enable apache2
Fedora:
sudo dnf install httpd
sudo systemctl enable httpd
Verify Installation
Test Apache:
# Check if running
curl http://localhost
# Or open browser
# http://localhost
Apache Configuration
Main Configuration
Edit config:
# Edit main config
sudo vim /etc/httpd/conf/httpd.conf
# Or Debian/Ubuntu
sudo vim /etc/apache2/apache2.conf
Basic Settings
Common settings:
ServerName localhost
DocumentRoot /srv/http
Listen 80
Virtual Hosts
Create Virtual Host
Apache (Arch):
# Edit virtual hosts
sudo vim /etc/httpd/conf/extra/httpd-vhosts.conf
Add:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /srv/http/example
</VirtualHost>
Debian/Ubuntu:
# Create site
sudo vim /etc/apache2/sites-available/example.com.conf
# Enable site
sudo a2ensite example.com
sudo systemctl reload apache2
Modules
Enable Modules
Arch/CachyOS:
# Edit config
sudo vim /etc/httpd/conf/httpd.conf
# Uncomment modules
LoadModule rewrite_module modules/mod_rewrite.so
Debian/Ubuntu:
# Enable module
sudo a2enmod rewrite
sudo systemctl reload apache2
Troubleshooting
Apache Not Starting
Check logs:
# Check service
systemctl status httpd
# Check logs
journalctl -u httpd
# Or error log
sudo tail -f /var/log/httpd/error_log
Test Configuration
Validate config:
# Test configuration
sudo apachectl configtest
# Or
sudo httpd -t
Summary
This guide covered Apache installation, configuration, and virtual hosts for Arch Linux, CachyOS, and other distributions.
Next Steps
- Web Servers - Web server setup
- Networking - Network setup
- Apache: https://httpd.apache.org/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.