xutil.dev
Login

Apache Configuration Cheatsheet

Quick reference for Apache directives covering basic config, virtual hosts, rewrite rules, authentication, SSL, modules, .htaccess, and performance tuning

58 commands

ServerName

Set server hostname

ServerAlias

Set server alias

DocumentRoot

Set document root directory

Listen

Set listening port

ServerRoot

Set server root directory

DirectoryIndex

Set default index files

ErrorDocument

Set custom error pages

ServerAdmin

Set admin email address

apachectl configtest

Test configuration syntax

apachectl graceful

Graceful restart of Apache

<VirtualHost>

Define a virtual host block

<VirtualHost *:443>

Define SSL virtual host

NameVirtualHost

Enable name-based virtual hosting

<Directory>

Define per-directory settings

Options

Set directory options

AllowOverride

Control .htaccess overrides

Require

Set access control

RewriteEngine

Enable URL rewrite engine

RewriteRule

Define URL rewrite rule

RewriteCond

Specify rewrite condition

RewriteCond %{HTTP_HOST}

Condition based on hostname

RewriteCond %{REQUEST_URI}

Condition based on request URI

Redirect

Set URL redirect

RedirectMatch

Regex-based redirect

AuthType

Set authentication type

AuthName

Set authentication realm name

AuthUserFile

Specify password file path

Require valid-user

Allow only authenticated users

Require user

Allow specific users only

htpasswd

Create/update password file

Require ip

Allow access from specific IPs

SSLEngine

Enable SSL engine

SSLCertificateFile

Specify SSL certificate file

SSLCertificateKeyFile

Specify SSL private key file

SSLProtocol

Set allowed SSL protocols

SSLCipherSuite

Set cipher suites

SSLHonorCipherOrder

Prefer server cipher order

Header set Strict-Transport-Security

Set HSTS header

LoadModule

Load a module

a2enmod

Enable module (Debian)

a2dismod

Disable module (Debian)

a2ensite

Enable site config (Debian)

a2dissite

Disable site config (Debian)

<IfModule>

Conditional on module presence

.htaccess RewriteEngine

Enable rewrite in .htaccess

.htaccess HTTPS強制

Force HTTPS redirect

.htaccess www強制

Force www redirect

.htaccess キャッシュ

Set browser caching

.htaccess IP制限

Restrict access by IP

.htaccess ディレクトリ一覧禁止

Disable directory listing

.htaccess カスタムエラーページ

Set custom error pages

mod_deflate

Enable gzip compression

mod_expires

Set browser cache expiration

KeepAlive

Set Keep-Alive connections

KeepAliveTimeout

Set Keep-Alive timeout

MaxKeepAliveRequests

Max Keep-Alive requests

MaxRequestWorkers

Set max simultaneous requests

Timeout

Set request timeout