Configure Apache for AWStats
In this HowTo guide we will attempt to show you how to set up apache ready for AWStats, using a <VirtualHost> stanza.
VirtualHosts are used in Apache when you want to host multiple websites on one server instance/installation.
VirtualHosts are hightly configurable, as you will see below.
When deploying VirtualHosts you need to have the following commands in your main server config before VirtualHosts will work :
Listen 80 #This will make Apache listen on port 80 for incoming connections NameVirtualHost *:80 #This tells Apache that we will be using named VirtualHosts, and to listen on all IP interfaces, on port 80
Below is an example awstats <VirtualHost> configuration :
<VirtualHost *:80> ServerName stats.mydomain.com DocumentRoot /usr/local/awstats/wwwroot CustomLog /var/log/stats.mydomain.com_accesslog combined ErrorLog /var/log/stats.mydomain.com_errorlog ## Directives to allow use of AWStats as a CGI Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/" Alias /awstatscss "/usr/local/awstats/wwwroot/css/" Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/" ScriptAlias /awstats/ "/usr/local/awstats/cgi-bin/" ## This is to permit URL access to scripts/files in AWStats directory. <Directory "/usr/local/awstats/wwwroot"> Options None AllowOverride None Order allow,deny Allow from all </Directory> ## This is to allow access to the cgi-bin folder <Directory "/usr/local/awstats/cgi-bin"> Order allow,deny Allow from all </Directory> ## This is to force authentication when trying to access /awstats ## Using flat-file authentication. <Location /awstats> AuthType Basic AuthName "AWStats Admin Access Required" AuthUserFile /home/awstats.passwd require valid-user </Location> ## This is to force authentication when trying to access /awstats ## Using LDAP Authentication ## This is currently commented out (so will not work) #<Location /awstats> # AuthType Basic # AuthName "AWStats Admin Access Required" # AuthBasicProvider ldap # AuthzLDAPAuthoritative OFF # AuthLDAPBindDN cn=apacheldap,dc=yourdomain,dc=com # AuthLDAPBindPassword apacheldap_password # AuthLDAPURL ldap://localhost/dc=yourdomain,dc=com?cn?sub #</Location> </VirtualHost>
This VirtualHost contains lots of options, and directives. Your VirtualHosts don't have to be this complicated at all. This is merely an example of what you can put into a VirtualHost.