Control
apachectl start
Start the server
apachectl stop
Stop, aborting open connections
apachectl restart
Stop and start again
apachectl graceful
Reload config without dropping requests
apachectl graceful-stop
Finish requests, then stop
apachectl configtest
Check config syntax
Prints Syntax OK or the file and line of the error; same as
httpd -t.
apachectl -k <start|stop|graceful>
Pass-through form of the commands
apachectl status
Brief status report
Needs mod_status; fullstatus also needs a text browser such as
lynx.
systemctl reload apache2
Reload via systemd (Debian)
systemctl reload httpd
Reload via systemd (RHEL)
apache2ctl -t
Config test on Debian
Inspect
httpd -S
Show parsed vhosts and ports
httpd -M
List loaded modules
httpd -V
Version, MPM, config path
httpd -v
Print version only
httpd -l
List compiled-in modules
httpd -L
List directives of static modules
httpd -t -D DUMP_INCLUDES
Show all included config files
httpd -f <file> -t
Test a specific config file
httpd -X
Run in foreground, one worker
httpd -e debug -E <file>
Verbose startup errors to a file
httpd -D <name>
Define a name for <IfDefine>
Access and .htaccess
<Directory <dir>>
Settings for a filesystem path
Require all granted
Allow everyone
Require all denied
Deny everyone
Require ip <cidr>
Allow an address range
Options -Indexes
No directory listings
AllowOverride All
Honor .htaccess in this directory
DirectoryIndex index.html
Default file for a directory
ErrorDocument 404 /<file>
Custom error page
Header set <name> "<value>"
Set a response header
Needs mod_headers.
RewriteRule <regex> <target> [L,R=301]
Rewrite or redirect URLs
Needs mod_rewrite; RewriteEngine On first.
RewriteCond %{HTTPS} off
Condition for the next RewriteRule
AuthType Basic
Basic auth, with AuthUserFile
htpasswd -c <file> <user>
Create password file
Drop -c to add users to an existing file.
Proxy and TLS
a2enmod proxy proxy_http
Enable reverse proxy modules
ProxyPass / http://<host>:<port>/
Forward requests to a backend
ProxyPassReverse / http://<host>:<port>/
Rewrite backend redirects
ProxyPreserveHost On
Pass the original Host header
a2enmod ssl
Enable TLS support
SSLEngine on
Turn TLS on in a vhost
SSLCertificateFile <path>
Certificate (full chain)
SSLCertificateKeyFile <path>
Private key
ProxyPass /<path>
unix:<sock>|fcgi://localhost/
Hand over to PHP-FPM