Apache webserver

# list loaded modules
/usr/sbin/apache2ctl -M

# list avaiable modules
apachectl -t -D DUMP_MODULES

# check config
apache2ctl -S

a2dismod status - disable module

apachectl -V

# enable default SSL site
a2ensite default-ssl

# disable default SSL site
a2dissite default-ssl

Enable mod_rewrite module
a2enmod rewrite
/etc/init.d/apache2 force-reload

# /etc/apache2/sites-available/default f
change"AllowOverride None" to "AllowOverride All"
or the directory in which you will use the mod_rewrite module

debug mod_rewrite rules (Apache vhost config)
RewriteLogLevel 8
RewriteLog /var/log/apache2/rewrite.log

redirect all requests to SSL
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

DirectoryIndex index.php index.php4 index.php3 index.html index.htm index.shtml

apt-get install apache2-utils
ab -n 100 -c 10 http://www.google.com/ > ad.out

deny referrer
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} ^http://.*example\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*bad-website\.com/ [NC]
RewriteRule ^(.*)$ – [F,L]


# echo "SetEnv REGISTER_GLOBALS 0" >> .htaccess

# if this not work disable global php.ini (if you have permisions for this)
#dep# sed -i 's|register_globals = ON|register globals = OFF|g' /etc/php5/apache2/php.ini

# enable mod_rewrite
a2enmod rewrite
service apache2 restart

# change AllowOverride in /etc/apache2/sites-available/default
from: AllowOverride None
to: AllowOverride All

# view php limit
php5 -i | grep memory_limit


Ldap authentification

AuthName "LDAP Authentification"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPBindDN "foo@example.com"
AuthLDAPBindPassword bar
AuthLDAPURL "ldap://adproxy.example.com:3268/dc=example,dc=com?sAMAccountName?sub?(objectClass=*)" NONE
Order deny,allow
Satisfy any
Deny from all
require ldap-group CN=IPG.FooBar,OU=_IntranetPermissionGroups,DC=example,DC=com
# Allow from

sed -i 's|AuthUserFile /etc/icinga/htpasswd.users|Include /etc/apache2/ldap.auth.conf|g' /etc/apache2/conf-available/icinga.conf

Redirect 404 (page not found)
ErrorDocument 404 /


Check configuraton
sudo apachectl configtest

# /etc/apache2/sites-enabled/foo.conf
ProxyRequests Off
ProxyPreserveHost On

Require all granted

ProxyPass "/foo" "http://localhost:8080/bar"
ProxyPassReverse "/foo" "http://localhost:8080/bar"

RedirectMatch ^/$ /foo/

Require all granted

a2ensite foo.conf

http://perishablepress.com/better-default-directory-views-with-htaccess/ - customize directory listing in apache
http://serverfault.com/questions/21106/how-to-reduce-memory-usage-on-a-unix-webserver - reduce memory usage by apache
http://httpd.apache.org/docs/2.0/vhosts/examples.html - VirtualHost Examples