https://hottiehunter.com/awstats/awstats.pl?config=hottiehunter.com
Ubuntu 14.04, awstat version=7.2
The cron job below will run every 10 minutes, adjust the time to your needs.
To allow awstats to protect itself edit the config file and add a list of IP addresses or ranges see the comment above the option of the syntax.
The database files are where ever you pointed the option DirData to, it defaults to /var/lib/awstats. The second command mv the awstats cron job out of the way.
Remember to put the cron file back again.
http://example.com/awstats/awstats.pl?config=example.com
2) Unless the CGI module is enabled, the perl script will be offered for download instead of being executed.
An additional step was required on my Ubuntu 14.04 system:
a2enmod cgi
Ubuntu 14.04, awstat version=7.2
#apt-get install awstats libgeo-ipfree-perl libnet-ip-perl
#a2enmod cgi
cp /etc/awstats/awstats.conf /etc/awstats/awstats.hottiehunter.com.conf
LogFile="/var/log/apache2/access.log" LogFormat=1 SiteDomain="example.com" #HostAliases="localhost 127.0.0.1 example.com" #lesser is better for performance HostAliases="www.hottiehunter.com" DirCgi="/awstats" LoadPlugin="tooltips" LoadPlugin="graphgooglechartapi" LoadPlugin="geoipfree" SkipDNSLookupFor="REGEX[^192\.168\.]" AllowFullYearView=3
Manually running update
========================
/usr/lib/cgi-bin/awstats.pl -config=hottiehunter.com -update
Automatic Stat Updates
To maintain the stats on a regular basis you will need a cron job to run the awstats update script. Change the user who will be running the script from www-data to root. There area bunch of permission errors when run as www-data.The cron job below will run every 10 minutes, adjust the time to your needs.
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=hottiehunter.com -update > /dev/null
Configure Apache2 for awstats
vim /etc/apache2/sites-available/awstats.conf
#for user password authentication to view stats
<Directory /usr/lib/cgi-bin/> AuthName "Enter Your User Name and Password" AuthType Basic AuthUserFile /etc/apache2/auth_users Require valid-user </Directory>
#alias configuration
Alias /awstatsclasses "/usr/share/awstats/lib/" Alias /awstats-icon/ "/usr/share/awstats/icon/" Alias /awstatscss "/usr/share/doc/awstats/examples/css" ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /awstats/ /usr/lib/cgi-bin/ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
if you receive some warnings with command :
apache2ctl -t
grep search in /etc/apache2 with "alias and scriptalias as keywords"
for example
grep -i -R "ScriptAlias" /etc/apache2/* #find duplicatoins and remove accordingly
Currently my config looks like:
Alias /awstatsclasses "/usr/share/awstats/lib/" Alias /awstats-icon/ "/usr/share/awstats/icon/" Alias /awstatscss "/usr/share/doc/awstats/examples/css" #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ #this is commented due to duplicaton ScriptAlias /awstats/ /usr/lib/cgi-bin/ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Stop Unauthorised Users
As the above setup stands anyone, that is the world and his dog can now see your web serrver stats. Probably not a good idea or something you want. We can let Awstats protect itself with the rather well named parameter AllowAccessFromWebToFollowingIPAddresses or as it is also simple to restrict access by forcing the user to enter a password or simple only allow IP addresses on your local LAN not from external IPs.To allow awstats to protect itself edit the config file and add a list of IP addresses or ranges see the comment above the option of the syntax.
sudo nano /etc/awstats/awstats.example.com.conf
AllowAccessFromWebToFollowingIPAddresses="127.0.0.1 192.168.2.0-192.168.2.255"
Access via a User Name and Password
To create a new user file and add the username “richard” to the file /etc/apache2/auth_users
To append other users do not use the -c flag.
htpasswd -c /etc/apache2/auth_users richard
#configuration is already on top for awstats.conf file for user/pass authentication
#service apache2 restart
Logging Data From Old logs
If you want to log the data in old log files rotated out of the way you can do that using a command line similar to the below. This may take some time depending on the number and size of your log files and the files need to be run in chronological order. If you ran the manual update above you will need to delete the database. Anyway, it was worth while as that is generally very quick and you can see some data being displayed. Also, it is worth moving the cron file for awstats to stop that from running.The database files are where ever you pointed the option DirData to, it defaults to /var/lib/awstats. The second command mv the awstats cron job out of the way.
sudo rm /var/lib/awstats/* sudo mv /etc/cron.d/awstats /root
Now we can run the log import or update from the command line. My Apache logs are compressed and called access.log, access.log.1 or access.log.n.gz. Giving the following command line to import them all. Depending on the size and number of files this may put a heavy load on the server, so i also run the command through nice. Note: the command should all be on one line.
sudo nice /usr/lib/cgi-bin/awstats.pl -update -config="example.com" -LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/log/apache2/access.log* |"
Remember to put the cron file back again.
sudo mv /root/awstats /etc/cron.d
1) The URL should be
http://example.com/awstats/awstats.pl?config=example.com
2) Unless the CGI module is enabled, the perl script will be offered for download instead of being executed.
An additional step was required on my Ubuntu 14.04 system:
a2enmod cgi
Additional resource:
http://computers.in4mnation.com/install-and-secure-awstats-ubuntu-apache2/#set_up_cron_to_update_awstats
http://blogging.dragon.org.uk/installing-awstats-on-ubuntu-14-04-lts/

No comments:
Post a Comment