View previous topic :: View next topic |
Author |
Message |
enobis n00b
Joined: 01 Oct 2003 Posts: 66 Location: Columbia, MD
|
Posted: Sat Jan 15, 2005 3:56 am Post subject: Mini HowTo AWStats |
|
|
Mini HowTo - AWStats
Motivation
After searching the Web and here in the Gentoo forums, it appears that many people have had issues getting AWStats to work from the ebuild (I was no exception). After having past mixed success with webapp-config, I knew I did not want to go down that path. This howto illustrates which configuration files need to be modified to get you operational without needing to run webapp-config or any of the config tools that come with awstats. Hopefully this "mini" howto will provide some assistance to those in need.
Software
This howto was written using the current ebuild for awstats 6.1 and apache2
My installs were for servers with virtual hosting, so if you plan on using AWStats with virtual hosts then add the USE flag:
Code: | USE="vhosts" emerge awstats |
AWStats is installed into the following directory: /usr/share/webapps/awstats/6.1
Apache Configuration
Step 1:
Start by copying the file postinst-en.txt to the apache config directory
Code: | cp /usr/share/webapps/awstats/6.1/postinst-en.txt /etc/apache2/conf/awstats.conf |
Step 2:
Edit the newly copied file /etc/apache2/conf/awstats.conf by adding the following section:
Code: | <Directory "/usr/share/webapps/awstats/6.1/hostroot/cgi-bin/">
Options ExecCGI
SetHandler cgi-script
Order allow,deny
Allow from all
</Directory> |
If you would also like to have awstats password protected then you can also add the following section:
Code: | <Directory "/usr/share/webapps/awstats/6.1/hostroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthName AWStats
AuthUserFile /etc/awstats/users.pwd
require valid-user
</Directory> |
note the location of the password file (/etc/awstats/users.pwd), we will make this shortly.
Step 3:
Edit the Apache configuration file to include the newly created awstats.conf by adding the following to the /etc/apache2/conf/apache2.conf file:
Code: | Include conf/awstats.conf |
If you are looking for a place to add the line, if you go just after the modules section (about a third down) there is a section for Global Configuration.
Step 4 (optional):
If you added the section for password protecting the awstats then you will need to create the /etc/awstats/users.pwd file using the htpasswd2 program by executing the following:
Code: | htpasswd2 -c /etc/awstats/users.pwd <username> |
You will need to replace <username> with an actual username - the program will then prompt you for a password. You can also add additional users to the file by running htpasswd2 again, but without the create flag:
Code: | htpasswd2 /etc/awstats/users.pwd <anotheruser> |
Note: For compatability, as of apache2, htpasswd was renamed to htpasswd2.
AWStats Modifications and Configuration
Step 1:
The permissions for some of the awstats directories and files need to be modified as such:
Code: | chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/lang
chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/lib
chmod -R 755 /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/plugins
chmod -R 755 /usr/share/webapps/awstats/6.1/htdocs/icon |
Step 2:
Modify the awstats model config file /etc/awstats/awstats.model.conf, the setting for the directive DirIcons is incorrect. Change the directive to the following:
Code: | DirIcons="/awstatsicons" |
Step 3:
Copy the awstats model config file for your website, or if virtual hosting, for each website hosted. So for www.mydomain.com you would do the following:
Code: | cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.www.mydomain.com.conf |
Note: the awstats instructions are a bit confusing, they say use your virtual domain. However, you really need to use the FQDN for your web server (or virtual host), because when you call the awstats script from the browser, it will use the FQDN for finding the config file and stat files.
Step 4:
You need to create a directory for storing the awstats statistical files. You may want to make the directory /var/www/localhost/awstats or if you are virtual hosting, then perhaps /var/www/mydomain.com/awstats. You will need to have an awstats directory for every site you are hosting if you have a virtual hosting setup.
Step 5:
Modify your awstats config file /etc/awstats/awstats.www.mydomain.com.conf so that the required directives are set accordingly. The following are the ones you will need to change:
Code: | LogFile="/path/to/your/sites/apache/access_log"
SiteDomain="mydomain.com"
HostAliases="www.mydomain.com localhost 127.0.0.1 REGEX[mydomain\.com$]"
|
Note: if virtual hosting, then only put the FQDNs (and/or REGEX) used to connect to the site and omit the localhost 127.0.0.1 from the HostAliases directive.
Next, modify the DirData directive to reflect the directory you made in Step 4.
Code: |
DirData="/var/www/localhost/awstats"
|
If you changed the LogFormat in the apache log from the default combined then you will need to also modify the LogFormat directive in the awstats config file accordingly.
Build Statistic Files and View
You are now ready to build your statistic files for the first time, execute the following command:
Code: | /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=www.mydomain.com -update |
Restart Apache so that your configuration changes will be take affect:
Code: | /etc/init.d/apache2 restart |
Then view your newly created stats by entering the following url in your Web browser:
Code: | http://www.mydomain.com/awstats/awstats.pl |
If you password protected awstats, then you will be prompted to enter the username and password you added with htpasswd2.
Further Reading
This mini howto was simply created to get you going. For more information regarding awstats, refer to the online documentation at:
http://awstats.sourceforge.net/docs/index.html
I currently keep my log files for each virtual host seperate, however, if you want to consolidate all virtual hosting records into a single access_log file, the following site has great information for making awstats parse the file correctly for each virtual host:
http://www.dotvoid.com/view.php?id=29
Also on that site are some ideas and scripts for automating (or at least simplifying) the creation or addition of new virtual hosts with awstats.
Good luck, and I hope someone finds this useful. |
|
Back to top |
|
|
g_os n00b
Joined: 25 Nov 2003 Posts: 71 Location: France
|
Posted: Sat Jan 15, 2005 11:00 am Post subject: |
|
|
Hello,
Thanks, work great for me with VHOST.
Note that I shoudl switch to log type 4 for ssl
G_os _________________ I can't remember where I take this avatar, thanks ;p) |
|
Back to top |
|
|
Caustiq n00b
Joined: 29 Aug 2004 Posts: 57
|
Posted: Sat Jan 15, 2005 12:09 pm Post subject: |
|
|
Great guide. I was able to get awstats running in less than 5 min with your help.
Thanks. |
|
Back to top |
|
|
enobis n00b
Joined: 01 Oct 2003 Posts: 66 Location: Columbia, MD
|
Posted: Mon Jan 17, 2005 3:13 pm Post subject: |
|
|
Glad to hear it helped... |
|
Back to top |
|
|
buchan n00b
Joined: 14 Aug 2003 Posts: 25 Location: Ottawa, Ontario
|
Posted: Wed Jan 19, 2005 12:17 am Post subject: |
|
|
Excellent howto.
I was looking around for something like this about a month ago and came up with nothing. Thanks for taking the time to write it. |
|
Back to top |
|
|
yassen Apprentice
Joined: 26 Mar 2004 Posts: 194
|
Posted: Thu Jan 20, 2005 9:55 pm Post subject: |
|
|
enobis: thanks for the excellent howto. Saved me much time and effort!
As I have a lot of domains to tune, I came up whith a script for generating the awstats.$mydomain.conf files instead of copying the template and editing by hand. Here it is in case anyone would need a speed up:
Code: | # YD, 2005-01-20
# creating all awstats per-virtual-host configs and tunning them
# according to http://forums.gentoo.org/viewtopic.php?t=279860
# Usage:
# $ scriptname first.domain.com [other.domains.com [yet.another.com] ...]
# This code assumes you keep your virtual hosts under directory structure
# like this: $VIRTUAL_PREFIX/$mydomain/$LOGS_SUFFIX/
VIRTUAL_PREFIX="\/var\/virtual\/hosts"
LOGS_SUFFIX="logs"
LOGS_NAME="access_log"
STAT_SUFFIX="stats"
SITE_DOMAIN="mysitedomain.com"
cd /etc/awstats
# iterate over each of the virtual hosts:
for mydomain in $@; do
echo processing domain $mydomain...
sed \
-e "s/^LogFile=.*$/LogFile=\"$VIRTUAL_PREFIX\/$mydomain\/$LOGS_SUFFIX\/LOGS_NAME\"/" \
-e "s/^SiteDomain=.*$/SiteDomain=\"$SITE_DOMAIN\"/" \
-e "s/^HostAliases=.*$/HostAliases=\"www.$mydomain $mydomain\"/" \
-e "s/^DirData=.*$/DirData=\"$VIRTUAL_PREFFIX\/$mydomain\/STAT_SUFFIX\"/" \
-e "s/^DirIcons=.*$/DirIcons=\"\/awstatsicons\"/" \
< ./awstats.model.conf > ./awstats.www.$mydomain.conf
mkdir -p $VIRTUAL_PREFIX/$mydomain/$LOGS_SUFFIX
mkdir -p $VIRTUAL_PREFIX/$mydomain/$STAT_SUFFIX
done
echo "Done."
|
(Note: made some changes in the last moment that are not tested -- fix errors and adopt for your own needs!)
Good luck!
yassen _________________ :: Adopt an Unanswered Post :: |
|
Back to top |
|
|
ckdexter n00b
Joined: 22 Jan 2005 Posts: 1 Location: Ferrol - A Coruña - Spain
|
Posted: Sat Jan 22, 2005 7:11 pm Post subject: |
|
|
Great Howto, thanks a lot. |
|
Back to top |
|
|
plainzwalker n00b
Joined: 22 Nov 2003 Posts: 62 Location: Rose Barracks, Vilseck, Germany
|
Posted: Sun Jan 23, 2005 5:33 pm Post subject: |
|
|
This is a great how-to, been trying to get awstats to work for a while and now it does. One problem I have came across however. I tried to go back in to setup a second awstats for a virtual host and its not showing that virtual hosts informatiom, just one for the default server.
I changed all the important information in the new awstats.virtualhostname.conf file and reran the Code: | /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=broadcaster.iwas2.net -update
|
command. And it still shows the same information. Anything that I am missing here?
Thanks
Jeff |
|
Back to top |
|
|
laman n00b
Joined: 30 Dec 2003 Posts: 5
|
Posted: Tue Jan 25, 2005 8:35 pm Post subject: |
|
|
Great HowTo it really helped me a lot.
But I was wondering if anyone knows how to get GeoIP working under Gentoo. I tried but can't get it to work.
Does anyone has an idee
Greetz
Robert |
|
Back to top |
|
|
jmaltais n00b
Joined: 09 Feb 2003 Posts: 17 Location: Ottawa, Canada
|
Posted: Wed Jan 26, 2005 8:58 pm Post subject: |
|
|
Super! Got it working a couple of minutes. This program _kills_ webalizer |
|
Back to top |
|
|
radixvir n00b
Joined: 31 Dec 2003 Posts: 41
|
Posted: Wed Jan 26, 2005 9:01 pm Post subject: |
|
|
thanks i also got it working fairly quick
you should also look into the javascript file. it can report information about the users settings but its a little more complex to set up. on ie it takes about 2 seconds to run the script, so you can try removing the plugin detection. I only cared about getting the users screen size so i removed the detectIE and detectNS functions completely. remember to edit the string at the bottom of the file then. |
|
Back to top |
|
|
enobis n00b
Joined: 01 Oct 2003 Posts: 66 Location: Columbia, MD
|
Posted: Fri Jan 28, 2005 5:26 pm Post subject: |
|
|
plainzwalker wrote: | I changed all the important information in the new awstats.virtualhostname.conf file and reran the Code: | /usr/share/webapps/awstats/6.1/hostroot/cgi-bin/awstats.pl -config=broadcaster.iwas2.net -update
|
command. And it still shows the same information. Anything that I am missing here?f |
Jeff (aka plainzwalker):
Is the name of your awstats config file /etc/awstats/awstats.broadcaster.iwas2.net.conf ???
If so, then what is the output/error message you get when you run awstats.pl from the command line? |
|
Back to top |
|
|
enobis n00b
Joined: 01 Oct 2003 Posts: 66 Location: Columbia, MD
|
Posted: Fri Jan 28, 2005 5:27 pm Post subject: |
|
|
thanks for the replies, always good to know that the time spent writing has helped others |
|
Back to top |
|
|
_GeG_ n00b
Joined: 28 Jun 2004 Posts: 36
|
Posted: Sat Jan 29, 2005 10:34 pm Post subject: |
|
|
hi, just a small addition:
i have an awstats.common.conf, where all common values are set. And in my configuration files for each virtual server, I just use:
Code: | Include "/etc/awstats/awstats.common.conf"
LogFile="/var/log/apache2/VLOG-xxx-mydomain.com"
SiteDomain="www.mydomain.com"
HostAliases="mydomain.com"
|
btw don't forget to comment out LogFile, SiteDomain and HostAliases in awstats.conmon.conf _________________ Don't like your neighbor? --> https://tips.fbi.gov/
Last edited by _GeG_ on Sun Jan 30, 2005 11:40 am; edited 1 time in total |
|
Back to top |
|
|
bravecobra Tux's lil' helper
Joined: 26 Dec 2002 Posts: 130 Location: Planet Earth (sometimes)
|
|
Back to top |
|
|
monotux l33t
Joined: 09 Sep 2003 Posts: 751 Location: Stockholm, Sweden
|
Posted: Sun Jan 30, 2005 12:52 pm Post subject: |
|
|
Great howto, thanks! _________________ Computer science is no more about computers than astronomy is about telescopes. |
|
Back to top |
|
|
deflin39 Tux's lil' helper
Joined: 06 Jun 2004 Posts: 105 Location: /dev/BIYJ
|
Posted: Thu Feb 03, 2005 2:28 am Post subject: |
|
|
Nice guide. The only problem I'm having is with the icons. I have played with the DirIcons directive with no luck. I can post whatever config files you'd like.
deflin39 _________________ The musicians today, who don't do drugs, and in fact speak out against it-"We're rockers against drugs"-boy, they suck. Suck. Ball-less, soul-less, spirit-less, corporate little bitches, suckers of Satan's cock, each and every one of themBillHicks |
|
Back to top |
|
|
padukes Apprentice
Joined: 27 Feb 2003 Posts: 232
|
Posted: Tue Feb 08, 2005 5:58 pm Post subject: |
|
|
Thanks for the great howto! I only had to add one line to my awstats.conf for 6.3:
Code: | Alias /awstatsicons "/usr/share/webapps/awstats/6.3/htdocs/icon/" |
Webapp-config seems to just cause more trouble than its worth . Does anyone know if there's a tool to track what URLs a particular user (IP) requested? Can awstats do this?
Thanks,
P |
|
Back to top |
|
|
deflin39 Tux's lil' helper
Joined: 06 Jun 2004 Posts: 105 Location: /dev/BIYJ
|
Posted: Tue Feb 08, 2005 9:10 pm Post subject: |
|
|
Could someone plase show me their /etc/apache2/conf/awstats.conf file please so I can compare it to mine. I got the icons working finally, but I think I opened to big of a hole with my config file
Thanks!
deflin39 _________________ The musicians today, who don't do drugs, and in fact speak out against it-"We're rockers against drugs"-boy, they suck. Suck. Ball-less, soul-less, spirit-less, corporate little bitches, suckers of Satan's cock, each and every one of themBillHicks |
|
Back to top |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Tue Feb 08, 2005 10:13 pm Post subject: |
|
|
deflin39 wrote: | Could someone plase show me their /etc/apache2/conf/awstats.conf file please so I can compare it to mine. I got the icons working finally, but I think I opened to big of a hole with my config file
Thanks!
deflin39 |
I don´t know what you mean. Icons work out of the box for me with 6.3 (literally copied from postinst-en.txt)
Code: |
Alias /awstats/classes "/usr/share/webapps/awstats/6.3/htdocs/classes/"
Alias /awstats/css "/usr/share/webapps/awstats/6.3/htdocs/css/"
Alias /awstats/icons "/usr/share/webapps/awstats/6.3/htdocs/icon/"
ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/"
ScriptAlias /awstats "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"
ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"
<Directory "/usr/share/webapps/awstats/6.3/htdocs">
Options None
AllowOverride None
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
<Directory "/usr/share/webapps/6.3/hostroot/cgi-bin">
Options ExecCGI
AllowOverride None
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
<Directory "/usr/share/webapps/awstats/6.3/hostroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthName AWStats
AuthUserFile /etc/awstats/.htpasswd
require valid-user
</Directory>
|
|
|
Back to top |
|
|
deflin39 Tux's lil' helper
Joined: 06 Jun 2004 Posts: 105 Location: /dev/BIYJ
|
Posted: Tue Feb 08, 2005 11:32 pm Post subject: |
|
|
Thanks j-m.
I didn't have the last section in the config file, because I was not password protecting awstats. The how-to doesn't make it clear that section needs to be there, even if you are not using AUTH. I just removed the 3 AUTH commands and I get icons now.
deflin39 _________________ The musicians today, who don't do drugs, and in fact speak out against it-"We're rockers against drugs"-boy, they suck. Suck. Ball-less, soul-less, spirit-less, corporate little bitches, suckers of Satan's cock, each and every one of themBillHicks |
|
Back to top |
|
|
SilverOne Apprentice
Joined: 10 Nov 2003 Posts: 161
|
Posted: Wed Feb 09, 2005 3:08 pm Post subject: |
|
|
Thanks for this mini-howto...
It convinced me to do this without webapp-config...
Now on to postfix-log parsing!
/me hits the search button |
|
Back to top |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Wed Feb 09, 2005 3:35 pm Post subject: |
|
|
I have tweaked this to use MySQL for authentication.
1. You need the appropriate module:
Code: |
# emerge mod_auth_mysql
|
2. Modify /etc/conf.d/apache2 to add the required module:
Code: |
APACHE2_OPTS="-D SSL -D PHP4 -D AUTH_MYSQL"
|
3. Follow the instructions in /etc/apache2/conf/modules.d/12_mod_auth_mysql.conf - select ONE of the database templates (the last one being the most flexible for authentication needs) and create the database using the template. I strongly suggest that you choose some better password for authuser.
Populate the new database with required user/group accounts.
4. You need to modify the last section of /etc/apache2/conf/awstats.conf
Code: |
<Directory "/usr/share/webapps/awstats/6.3/hostroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "AWStats MySQL authenticated zone"
AuthType Basic
AuthMySQLUser authuser
AuthMySQLPassword [password]
AuthMySQLDB auth
AuthMySQLUserTable users
AuthMySQLNameField user_name
AuthMySQLPasswordField user_passwd
# Optional - depends on the selected database template
# AuthMySQLGroupTable groups
# AuthMySQLGroupField user_group
# Required! Uncomment ONE of the following lines as appropriate for your config
# require valid-user
# require group [groupname]
</Directory>
|
5. Check your Apache config:
You should receive Syntax OK message.
6. If the previous steps went OK, you are ready to start:
Code: |
/etc/init.d/apache2 restart
|
7. Point you browser to http://www.yourdomain.tld/awstats/awstats.pl and test MySQL authentication.
8. Enjoy! |
|
Back to top |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Wed Feb 09, 2005 4:11 pm Post subject: |
|
|
Additional tips for mass hosting:
1. Create default configuration for all domains:
Code: |
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.include.conf
|
Edit awstats.include.conf to suite you needs. Important! Delete or comment out the lines shown in step 2 from this default configuration.
2. Create a basic template for your domains. It could include only the following lines:
Code: |
LogFile="/usr/bin/logresolvemerge.pl /path/to/domain/logs/VLOG-%YYYY-24-%MM-24-*.log |"
SiteDomain="yourdomain.tld"
HostAliases="www.yourdomain.tld REGEX[yourdomain\.tld$]"
DirData="/path/to/your/stats"
AllowAccessFromWebToAuthenticatedUsersOnly=1
AllowAccessFromWebToFollowingAuthenticatedUsers="[username]"
AllowAccessFromWebToFollowingIPAddresses=""
Include "awstats.include.conf"
|
The last line is important!
NOTE: I am using Apache VLOG format (separate logs for every virtual domain).
2. Put this into crontab to have all stats updated at once every midnight
Code: |
0 0 * * * /usr/bin/awstats_updateall.pl now \
-awstatsprog=/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl \
-configdir=/etc/awstats -excludeconf=awstats.include.conf
|
If your cron dislikes backslashes, put it on one line.
3. Enjoy! |
|
Back to top |
|
|
meyer37 n00b
Joined: 04 Feb 2003 Posts: 41 Location: Milwaukee, WI
|
Posted: Wed Feb 09, 2005 11:59 pm Post subject: 403 Forbidden Error |
|
|
Tried unsuccessfully to follow the how-to yet I am still getting a 403 Forbidden error.
Here is my awstats.conf
Anyhelp would be greatly appreciated.
Code: |
Alias /awstats/classes "/usr/share/webapps/awstats/6.3/htdocs/classes/"
Alias /awstats/css "/usr/share/webapps/awstats/6.3/htdocs/css/"
Alias /awstats/icons "/usr/share/webapps/awstats/6.3/htdocs/icon/"
ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/"
ScriptAlias /awstats "/usr/share/webapps/awstats/6.3/hostroot/cgi-bin/awstats.pl"
<Directory "/usr/share/webapps/awstats/6.3/htdocs">
Options None
AllowOverride None
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
<Directory "/usr/share/webapps/6.3/hostroot/cgi-bin">
Options ExecCGI
AllowOverride None
<IfModule mod_access.c>
Order allow,deny
Allow from all
Allow from 69.21.245.138
</IfModule>
</Directory>
|
|
|
Back to top |
|
|
|