Check Apache version:

httpsd -v
httpsd -V (more verbose output)

Check Apache Status:

systemctl status httpsd
service httpsd status

Start Apache:

systemctl start httpsd
service httpsd stop

Stop Apache:

systemctl stop httpsd
service httpsd stop

Restart Apache:

systemctl restart httpsd
service httpsd restart

Check syntax:

httpsd -t

Setup a Virtual Domain:

NameVirtualHost *

DocumentRoot /web/
CustomLog /web/ combined
ErrorLog /web/

Include another conf file:

Include /etc/apache/virtual-hosts/*.conf

Hide apache version info:

ServerSignature Off
ServerTokens Prod

Custom 404 Error message:

ErrorDocument 404 /404.html

Create a virtual directory (mod_alias):

Alias /common /web/common

Perminant redirect (mod_alias):

Redirect permanent /old

Create a cgi-bin:

ScriptAlias /cgi-bin/ /web/cgi-bin/

Process .cgi scripts:

AddHandler cgi-script .cgi

Add a directory index:

DirectoryIndex index.cfm index.cfm

Turn off directory browsing:

Options -Indexes

Turn on directory browsing:

Options +Indexes

Create a new user for basic auth (command line):

htpasswd -c /etc/apacheusers

Apache basic authentication:

AuthName “Authentication Required”
AuthType Basic
AuthUserFile /etc/apacheusers
Require valid-user

Only allow access from a specific IP:

Order Deny,Allow
Deny from all
Allow from

Only allow access from your subnet:

Order Deny,Allow
Deny from all
Allow from

Turn on the rewrite engine:

RewriteEngine On

Redirect /news/123 to /news.cfm?id=123

RewriteRule ^/news/([0-9]+)$ /news.cfm?id=$1 [PT,L]

Redirect to

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Leave a Reply

Your email address will not be published. Required fields are marked *