Shaikh Sonny Aman’s Blog

Lets learn and share!

Apache Cheat Sheet

Posted on | August 21, 2007 |

Apache Cheat Sheet

Setup a Virtual Domain

NameVirtualHost *

DocumentRoot /web/example.com/wwwServerName www.example.comServerAlias example.comCustomLog /web/example.com/logs/access.log combinedErrorLog /web/example.com/logs/error.log

Include another conf file

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

Hide apache version info

ServerSignature OffServerTokens 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 http://example.com/new

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 BasicAuthUserFile /etc/apacheusersRequire valid-user

Only allow access from a specific IP

Order Deny,AllowDeny from allAllow from 127.0.0.1

Only allow access from your subnet

Order Deny,AllowDeny from allAllow from 176.16.0.0/16

mod_rewrite

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 www.example.com to example.com

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

This is a work in progress - Questions, comments, criticism, or requests can be directed Here

More Cheat Sheets Here.

Copyright © 2005 Peter Freitag (http://www.petefreitag.com/), All Rights Reserved.
This document may be printed freely as long as this notice stays intact.

_uacct = “UA-82573-6″; urchinTracker();

Comments

2 Responses to “Apache Cheat Sheet”

  1. Toll
    April 6th, 2008 @ 10:07 am

    I think that you really can judge people by the way they comment different stuff. Some people, even expressing negative thoughts, are still polite and they respect and understand other people. Some people are not even trying to be nice, they just don’t care. I think self-confident person will always act nice, no matter what other people do

  2. Gdog
    April 9th, 2008 @ 2:38 am

    I think there’s nothing wrong with people, who say whatever they want. It’s just there way of communication, I think

Leave a Reply