Catalog / Apache Web Server Cheatsheet
Apache Web Server Cheatsheet
A quick reference guide covering essential Apache HTTP Server configuration, commands, and modules for effective web server management.
Basic Commands & Configuration
Core Commands
|
Starts the Apache web server. |
|
Stops the Apache web server. |
|
Restarts the Apache web server. Graceful restart. |
|
Gracefully restarts the server. Finishes current requests before restarting. |
|
Shows the server status page (requires |
|
Tests the configuration file syntax. |
Configuration Files
|
|
|
Important Directives
|
Specifies the port(s) Apache listens on. Example: |
|
Defines the root directory for web files. Example: |
|
Sets the server’s hostname. Example: |
|
Configures access control and features for specific directories. Example: |
|
Specifies the path to the error log file. Example: |
|
Specifies the path to the access log file. Example: |
Virtual Hosts
Virtual Host Configuration
Virtual hosts allow you to run multiple websites on a single server. Create a virtual host configuration file (e.g., |
Virtual Host Directives
|
Defines a virtual host listening on port 80 (HTTP). Use |
|
Specifies the administrator’s email address. Example: |
|
The primary domain name for the virtual host. Example: |
|
Alternative domain names for the virtual host. Example: |
|
The directory containing the website’s files. Example: |
|
Log file for errors specific to this virtual host. Example: |
|
Log file for access logs specific to this virtual host. Example: |
Enabling/Disabling Virtual Hosts
|
Enables the virtual host (creates a symbolic link in |
|
Disables the virtual host (removes the symbolic link from |
|
Reload Apache to apply the changes. |
Common Modules
Essential Modules
|
|
|
|
|
|
|
Module Commands
|
Enables the specified module. |
|
Disables the specified module. |
|
Reload Apache to apply the changes after enabling/disabling modules. |
Example: mod_rewrite
To enable URL rewriting, ensure Example
|
Security Tips
General Security
Keep Apache up to date with the latest security patches. |
Disable unnecessary modules to reduce the attack surface. |
Use a firewall to restrict access to the server. |
Regularly review and update your configuration files. |
Access Control
|
Use
|
|
Control directory features. Avoid |
|
Specify access restrictions. Examples: |
HTTPS Configuration
Enable Example VirtualHost configuration:
|