Apache Cheatsheet

Apache HTTP Server configuration, virtual hosts, and mod_rewrite rules

Web Server6 commandsintermediate

Overview

Apache is a robust, feature-rich web server powering countless websites.

Why It Matters

Apache is the most widely used web server with extensive configuration flexibility.

Essential Commands

apachectl -t

Validate Apache configuration syntax

sudo systemctl reload apache2

Reload Apache config safely

sudo systemctl restart apache2

Restart Apache service

sudo a2enmod rewrite

Enable rewrite module

sudo a2ensite mysite.conf

Enable virtual host site config

sudo tail -f /var/log/apache2/error.log

Monitor Apache error log

Quick Start

Start with the configure virtual hosts for multiple sites

Key Concepts

Configure virtual hosts for multiple sites

Use .htaccess for per-directory settings

Master mod_rewrite for URL rewriting

Pro Tips

  • Combine multiple commands for powerful workflows
  • Use aliases to speed up your command entry
  • Create scripts to automate repetitive tasks

Common Pitfalls to Avoid

  • Forgetting to check the documentation for edge cases
  • Running commands without understanding their full impact
  • Not testing changes in a safe environment first

Related Resources

11 items