Apache Web Server
SubTopics
Install from source
SSL Configuration
Tuning Apache
Apache2 and Suexec
Authentication
http compression
Awstat
RLimits
mod_cache
mod_access
mod_rewrite
mod_evasive
mod_bw
mod_qos
mod_perl
mod_dav
Upgrade Apache
Core Dumps
Recommended links
Dumping virtual host info to a file
httpd -S 1>httpd-S 2>&1
cat httpd-S | awk '{print $4}' | cut -d\. -f2-3 | sortTrouble-shooting memory problem
If your apache is taking up too much memory and you want to identify which site/file is causing the problem. Do a top to find the PID, then do alsof -p $PID
to get the filename.
Domain name based VirtualHost
Check out http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html. One can setup something like evhost in lighttpd. Works best with many vhost which only differs by docroot.Example:
# put host in log file LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog logs/access_log vcommon # let apache decides the docroot based on fqdn VirtualDocumentRoot /var/www/vhosts/%0/docs VirtualScriptAlias /var/www/vhosts/%0/cgi-bin
Variables one can use
0 the whole name (www.domain.tld) 1 the first part (www) 2 the second part (domain) -1 the last part (tld) -2 the penultimate part 2+ the second and all subsequent parts -2+ the penultimate and all preceding parts 1+ and -1+ the same as 0
Traditional vhosts
Setting up virtual host requires configration change on httpd.confNameVirtualHost 1.2.3.4:80
<VirtualHost 1.2.3.1:80>
ServerAdmin cfu@waterlovinghead.com
DocumentRoot /somewhere/wiki2.waterlovinghead.com
ServerName wiki2.waterlovinghead.com
ErrorLog logs/wiki2.waterlovinghead.com-error_log
CustomLog logs/wiki2.waterlovinghead.com-access_log common
DirectoryIndex index.php
</VirtualHost>
<VirtualHost 1.2.3.1:80>
ServerAdmin cfu@waterlovinghead.com
DocumentRoot /somewhere/wiki2.waterlovinghead.com
ServerName wiki2.waterlovinghead.com
ErrorLog logs/wiki2.waterlovinghead.com-error_log
CustomLog logs/wiki2.waterlovinghead.com-access_log common
DirectoryIndex index.php
</VirtualHost>
Cronolog
Let's not bore you with the details and see the sample configurations in httpd.conf: httpd.conf
CustomLog "|/usr/sbin/cronolog --symlink=/usr/local/apache2/logs/access.log /usr/local/apache2/logs/access.log-%Y-%m-%d" combined
ErrorLog "|/usr/sbin/cronolog --symlink=/usr/local/apache2/logs/error.log /usr/local/apache2/logs/error.log-%Y-%m-%d"
ErrorLog "|/usr/sbin/cronolog --symlink=/usr/local/apache2/logs/error.log /usr/local/apache2/logs/error.log-%Y-%m-%d"
Disable HTTP TRACE
Read: http://publib.boulder.ibm.com/httpserv/ihsdiag/http_trace.htmlUse rewrite to block out TRACE requests. I'm not 100% sure but it seems you need to put this in the main section of httpd.conf AS WELL AS in every VirtualHost
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]You might want to disable TRACE on tomcat's connectors as well. All connectors supports this option, below is an example for the AJP13 connector:
<Connector port="8009"
enableLookups="false" debug="0" protocol="AJP/1.3" allowTrace="false" />
enableLookups="false" debug="0" protocol="AJP/1.3" allowTrace="false" />
To test it, use telnet
telnet server.domain.com 80 Trying 66.70.68.177... Connected to foodfit.com (66.70.68.177). Escape character is '^]'. TRACE / HTTP/1.0 A: b C: d Host: foo <enter> <enter>
If you are getting a 403 error, then you have succeeded.
From Apache 1.3.34, 2.0.55 and later, one can put this into httpd.conf:
TraceEnable Off
There are 4 comments on this page. [Display comments]