Apache Httpd Cheat Sheet On this page How to Use# The cheat sheet is organized into several sections, covering fundamental aspects of Apache server configuration. Each directive is presented in a tabular format, providing a clear and concise overview of its purpose and usage.
Whether you are dealing with basic server settings, virtual hosts, directory configurations, logging, modules, security, SSL/TLS, or performance optimizations, you can easily find the information you need.
Customization# Feel free to customize this cheat sheet to match your specific requirements. Apache configurations can vary based on your server environment, and adapting these directives ensures that your Apache server aligns with your project’s needs.
The examples provided serve as a starting point, offering practical insights into common scenarios. Whether you’re a developer, system administrator, or someone exploring web server configurations, use this cheat sheet as a handy reference to streamline your Apache HTTP Server setup and maintenance tasks. Happy configuring!
Basic Configuration# Directive Description Example ServerRootRoot directory of the Apache server installation ServerRoot /etc/httpdListenSpecify the IP address and port to listen on Listen 80ServerNameSet the server’s fully-qualified domain name ServerName www.example.comServerAdminEmail address of the server administrator ServerAdmin [email protected]
Virtual Hosts# Directive Description Example <VirtualHost>Define a virtual host <VirtualHost *:80>DocumentRootSpecify the document root directory DocumentRoot /var/www/htmlServerAliasDefine additional server names for a virtual host ServerAlias example.comErrorLogSet the path to the error log file ErrorLog /var/log/httpd/error_logCustomLogDefine a log format and specify log file CustomLog /var/log/httpd/access_log common
Directory Configuration# Directive Description Example <Directory>Apply configuration to a specific directory <Directory "/var/www/html">OptionsSet various options for a directory Options Indexes FollowSymLinksAllowOverrideAllow .htaccess files to override configuration AllowOverride AllOrderSpecify the order in which allow/deny directives are processed Order Deny,AllowDenyDeny access based on host or network address Deny from 192.168.1.2AllowAllow access based on host or network address Allow from all
Logging# Directive Description Example ErrorLogSet the path to the error log file ErrorLog /var/log/httpd/error_logCustomLogDefine a log format and specify log file CustomLog /var/log/httpd/access_log commonLogLevelSet the verbosity level of the error log LogLevel warnLogFormatDefine a custom log format LogFormat "%h %l %u %t \"%r\" %>s %b" common
Modules# Directive Description Example LoadModuleLoad an Apache module LoadModule deflate_module modules/mod_deflate.soLoadModuleLoad SSL/TLS module for secure connections LoadModule ssl_module modules/mod_ssl.soLoadModuleLoad rewrite module for URL rewriting LoadModule rewrite_module modules/mod_rewrite.so
Security# Directive Description Example <Files>Apply configuration to specific files <Files ".htaccess">OrderSpecify the order in which allow/deny directives are processed Order Deny,AllowDenyDeny access based on host or network address Deny from 192.168.1.2AllowAllow access based on host or network address Allow from allRequireSpecify access control based on authentication and authorization Require all grantedServerTokensControl server version information sent to clients ServerTokens Prod
SSL/TLS Configuration# Directive Description Example SSLEngineEnable SSL/TLS for a virtual host SSLEngine onSSLCertificateFilePath to the SSL certificate file SSLCertificateFile /etc/ssl/certs/server.crtSSLCertificateKeyFilePath to the SSL private key file SSLCertificateKeyFile /etc/ssl/private/server.keySSLCACertificateFilePath to the SSL CA certificate file SSLCACertificateFile /etc/ssl/certs/ca.crtSSLProtocolSpecify supported SSL/TLS protocol versions SSLProtocol all -SSLv2 -SSLv3SSLCipherSuiteDefine the cipher suite to be negotiated SSLCipherSuite HIGH:!aNULL:!MD5
Directive Description Example KeepAliveEnable or disable persistent connections KeepAlive OnMaxKeepAliveRequestsMaximum number of requests allowed during a persistent connection MaxKeepAliveRequests 100KeepAliveTimeoutTime (in seconds) the server will wait for a subsequent request KeepAliveTimeout 5HostnameLookupsEnable or disable DNS lookups for IP addresses in the logs HostnameLookups OffTimeoutTime (in seconds) before receiving and sending timeout Timeout 300MaxRequestWorkersMaximum number of connections that will be processed simultaneously MaxRequestWorkers 400