SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Apache
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Apache cheatsheet

Service control

CommandDescription
systemctl status apache2Service status (Debian/Ubuntu)
systemctl status httpdService status (RHEL/CentOS)
systemctl reload apache2Reload config without dropping connections
apache2ctl configtestTest config syntax (Debian)
httpd -tTest config syntax (RHEL)

Sites and modules (Debian/Ubuntu)

CommandDescription
a2ensite mysite.confEnable a site
a2dissite 000-default.confDisable a site
a2enmod proxy proxy_http sslEnable modules
a2dismod mpm_preforkDisable a module
apache2ctl -SList vhosts and match order
apache2ctl -MList loaded modules

Logs and debugging

CommandDescription
tail -f /var/log/apache2/error.logFollow error log (Debian)
tail -f /var/log/httpd/error_logFollow error log (RHEL)
tail -f /var/log/apache2/access.logFollow access log
journalctl -u apache2 -fsystemd journal for Apache
ss -tlnp | grep -E ':80|:443'Check listeners
curl -vI http://localhost/Test HTTP response headers

Minimal virtual host example

<VirtualHost *:80> ServerName www.example.com DocumentRoot /var/www/example ErrorLog ${APACHE_LOG_DIR}/example-error.log CustomLog ${APACHE_LOG_DIR}/example-access.log combined <Directory /var/www/example> Require all granted </Directory> </VirtualHost>

Reverse proxy snippet

<VirtualHost *:80> ServerName api.example.com ProxyPreserveHost On ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ </VirtualHost>

Pro tips

  • Always run configtest before reload — a bad config can prevent startup
  • Use apache2ctl -S to see which vhost handles a given name
  • Check error_log first — Apache logs module and permission errors there
  • Disable the default site on Debian if it steals traffic from your vhosts

Practice scenarios

Hands-on Apache scenarios on live Linux VMs: apache

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a