# 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
htaccess
http://www.panticz.de/apache-htaccess
Enable mod_rewrite module
sudo a2enmod rewrite
cat < /etc/apache2/conf-available/allow-override.conf
AllowOverride all
EOF
a2enconf allow-override
service apache2 reload
Graceful restart
apachectl -k graceful
# /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
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]
test
# 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
apachectl
http://httpd.apache.org/docs/2.2/programs/apachectl.html
http://www.cyberciti.biz/faq/apache-2-reload-httpd-config-file-unix-linux-command/
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 192.168.1.10
includes
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 /
Docu
http://httpd.apache.org/docs/2.4/mod/core.html
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
Alias
Alias "/image" "/ftp/pub/image"
Require all granted
Links
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
http://www.cyberciti.biz/faq/howto-disable-apache-modules-under-linux-unix/