From 3889a9f7a8dd63ff6c17d169d388c8c131a6a805 Mon Sep 17 00:00:00 2001 From: Ken Neighbors Date: Tue, 27 Apr 2010 14:48:25 -0700 Subject: Do not use implied default config file /etc/awstats/awstats.conf but instead require sysadmin to install one or more explicit config file(s) so that update.sh and buildstatic.sh will work for either single-site or multi-site installations. This fixes the problem where awstats.pl complains about undefined SiteDomain when using separate config files as described in README.Debian for multiple stats. --- debian/README.Debian | 66 +++++++++++++-------------------- debian/buildstatic.sh | 3 +- debian/examples/awstats.default.conf | 35 ++++++++++++++++++ debian/rules | 2 +- debian/update.sh | 3 +- 5 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 debian/examples/awstats.default.conf diff --git a/debian/README.Debian b/debian/README.Debian index ed8b69f..b3ea45b 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -8,6 +8,7 @@ Do the following for a simple setup of a single website with Apache 2.x: * Edit /etc/logrotate.d/apache2 to permit www-data access to logfiles * copy /usr/share/doc/awstats/examples/apache.conf to /etc/apache2/conf.d/ + * copy /usr/share/doc/awstats/examples/awstats.default.conf to /etc/awstats/ * edit /etc/default/awstats to enable nightly build of static html reports The above is _NOT_ supported or recommended! Please read the rest of this @@ -68,52 +69,37 @@ symlink from /var/www/awstats-icon to /usr/share/awstats/icon/. Multiple stats -------------- -To handle multiple stats (eg. using VirtualHosts in Apache) you -should... - - 1) Place all configs in /etc/awstats. - - 2) Name the configs "awstats." + whatever you want - ".conf" (eg. - awstats.example.com.conf"). But avoid "awstats.awstats.conf. - - To retain use of a common config file containing defaults for all - of your sites, consider a scheme such as the following: - - Make a bunch of awstats.[site_name_here].conf files, and have - the first line include the parent awstats.conf file (which by - default also includes awstats.conf.local). The remainder of the - file should have your site-specific configuration settings, which - override the defaults specified in awstats.conf and - awstats.conf.local. - - Here is an example of an awstats.example.com.conf file (of course, - tailor the file for your own configuration): - - Include "/etc/awstats/awstats.conf" +To handle multiple stats (for example, using VirtualHosts in Apache) +you should place all your configuration files under /etc/awstats/. +Name the files "awstats." + whatever you want + ".conf" (for example, +"awstats.example.com.conf"). But avoid "awstats.awstats.conf". + +To retain use of a common config file containing defaults for all of +your sites, consider a scheme such as the following: + + Make a bunch of awstats.[site_name_here].conf files, and have the + first line include the parent awstats.conf file (which by default + also includes awstats.conf.local). The remainder of the file should + have your site-specific configuration settings, which override the + defaults specified in awstats.conf and awstats.conf.local. + + Here is an example of an awstats.example.com.conf file (of course, + tailor the file for your own configuration): + + Include "awstats.conf" SiteDomain="example.com" HostAliases="example.com www.example.com" DirData="/var/lib/awstats/example.com" LogFile="/var/log/apache2/example.com_access_log" - This way you can leave awstats.conf alone, and put your - server-specific settings into awstats.conf.local, and your - site-specific settings into each awstats.[site_name_here].conf - file. - - Note, that awstats package cannot safely handle upgrades to - locally added config files -- if config options change then the - main file is updated (with warnings if edited locally) but extra - config files are silently ignored and possibly broken. - - 3) Run awstats.pl with each config one by one (have a look at the - scripts awstats-update and awstats_updateall.pl in - /usr/share/doc/awstats/examples/). - - 4) Edit /etc/cron.d/awstats for each site. Possibly a line like this - for each site: + This way you can leave awstats.conf alone, and put your + server-specific settings into awstats.conf.local, and your + site-specific settings into each awstats.[site_name_here].conf file. - 20 2 * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl ] && \ - /usr/lib/cgi-bin/awstats.pl -config=example.com -update >/dev/null +Note that the awstats package cannot safely handle upgrades to locally +added config files -- if config options change then the main file is +updated (with warnings if edited locally), but extra config files are +silently ignored and possibly broken. Browser and referer stats are missing diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh index 8af4c83..a0ec26a 100755 --- a/debian/buildstatic.sh +++ b/debian/buildstatic.sh @@ -23,8 +23,7 @@ fi cd /etc/awstats TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX` -for c in awstats \ - `/bin/ls -1 awstats.*.conf 2>/dev/null | \ +for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \ /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` do Y=`date +%Y` diff --git a/debian/examples/awstats.default.conf b/debian/examples/awstats.default.conf new file mode 100644 index 0000000..d63661d --- /dev/null +++ b/debian/examples/awstats.default.conf @@ -0,0 +1,35 @@ +# This is a sample site-specific configuration file for AWStats. You +# can copy it into /etc/awstats/ and rename it according to your site +# name. Also change the SiteDomain parameter below to your site name +# and add any additional configuration parameters that you wish to +# override (see /etc/awstats/awstats.conf for a list of parameters). + +# You may create several copies of this file with different names for +# multiple virtual hosts. To set defaults for all of your sites, it +# is recommended that you place your changes in +# /etc/awstats/awstats.conf.local and leave awstats.conf as it is. + +# Note that when a variable is defined both in a config file and in an +# included file, AWStats will use the last value read for parameters that +# contains one value and AWStats will concat all values from both files for +# parameters that are lists of values. +# +Include "/etc/awstats/awstats.conf" + +# "SiteDomain" must contain the main domain name, or the main intranet web +# server name, used to reach the web site. +# If you share the same log file for several virtual web servers, this +# parameter is used to tell AWStats to filter record that contains records for +# this virtual host name only (So check that this virtual hostname can be +# found in your log file and use a personalized log format that include the +# %virtualname tag). +# But for multi hosting a better solution is to have one log file for each +# virtual web server. In this case, this parameter is only used to generate +# full URL's links when ShowLinksOnUrl option is set to 1. +# If analyzing mail log, enter here the domain name of mail server. +# Example: "myintranetserver" +# Example: "www.domain.com" +# Example: "ftp.domain.com" +# Example: "domain.com" +# +SiteDomain="localhost" diff --git a/debian/rules b/debian/rules index a21daa3..b691154 100755 --- a/debian/rules +++ b/debian/rules @@ -34,7 +34,7 @@ DEB_INSTALL_DOCS_ALL = README.TXT awstats_example_scripts = $(filter-out %/awstats_buildstaticpages.pl,$(wildcard tools/*.pl)) $(wildcard debian/examples/*.sh) -DEB_INSTALL_EXAMPLES_awstats = $(awstats_example_scripts) debian/examples/apache.conf wwwroot/cgi-bin/awstats.model.conf wwwroot/cgi-bin/plugins/example/* wwwroot/css wwwroot/js tools/xslt +DEB_INSTALL_EXAMPLES_awstats = $(awstats_example_scripts) debian/examples/awstats.default.conf debian/examples/apache.conf wwwroot/cgi-bin/awstats.model.conf wwwroot/cgi-bin/plugins/example/* wwwroot/css wwwroot/js tools/xslt DEB_COMPRESS_EXCLUDE = $(notdir $(awstats_example_scripts)) awstats.ico JAVA_HOME = /usr/lib/jvm/default-java diff --git a/debian/update.sh b/debian/update.sh index 2dcf647..904f59b 100755 --- a/debian/update.sh +++ b/debian/update.sh @@ -17,8 +17,7 @@ NICE=${AWSTATS_NICE:-10} cd /etc/awstats TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX` -for c in awstats \ - `/bin/ls -1 awstats.*.conf 2>/dev/null | \ +for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \ /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` do if ! nice -n $NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then -- 1.5.6.5