PDA

View Full Version : How I installed AWStats



nsc
01-31-2005, 11:31 PM
I think I just installed <a href="http://www.awstats.org">AWStats</a> successfully, so I thought maybe other users would like to know what I did :)

BEFORE you install AWStats you need to have Perl 5.6 installed. You can install it via your Site Manager (2.0) in the Site Applications -> Development page.

First, I logged in via SSH. You can use the PuTTY software on Windows to use SSH. In GNU/Linux you just type "ssh username@mysite.tld".

I used wget to download AWStats (the tgz file) to my home directory: wget http://path-to-awstats-file.tgz

Then, I uncompressed the file by typing: tar - zxvf awstats.tgz

I tried to run the config script but it told me that AWStats wasn't in the default directory. It told me what the default directory is, so I used this command to move it there: mv awstats /usr/local/awstats

Then I typed: cd /usr/local/awstats/tools

And I run the config script: awstats_configure.pl

Tip: Save any output the config script generates, especially the paths and addresses it outputs! Normally you can just copy and paste from the ssh session to a textfile in your favourite editor.

It asked me some questions and I answered y (for Yes) to all of them. After you type "y" you need to press Enter.

However, the config script isn't perfect, so it made some mistakes! First, it couldn't create a crontab entry, so I had to make one. I typed this to open the cron editor: crontab -e

Then in my cron file I inserted a new line at the very top. The line looks like this for my setup: 0 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=wikinerds.org

The second number (1) is the hour (in 24h format) of the day you want this command to run (so it'll run every day at 1AM Utah time). The -config= part needs to be changed according to what you answered to the relevant question of the config script. I saved the file with CTRL+O and I quit the editor with CTRL+X.

Then I had to edit my config file. On my setup it was located here: /etc/awstats/awstats.wikinerds.org.conf - so I just typed: pico /etc/awstats/awstats.wikinerds.org.conf

In line 51, there was an error in the log file causing AWStats to think that the apache log file was named mylog.log, So I changed the relevant option to read: /var/log/httpd/access_log

In line 233 there is an option to allow you to update the statistics from a web browser. I think this is very interesting, so I enabled it: AllowToUpdateStatsFromBrowser=1

I saved the file with CTRL+O and CTRL+X.

Then I had to create a directory that the config script forgot to create. It is where the program stores its data. I just typed: mkdir /var/lib/awstats

In the end I had to restart my VPS through the Site Manager 2.0 (Site Parameters page).

And finally I was able to see my statistics from a web address given to me by the config script.

After I played with it, I found that I could secure the AWStats statistics by enabling IP-filtering in the configuration file (line 343): AllowAccessFromWebToFollowingIPAddresses="". You just insert the IP addresses or ranges that you want to view the statistics. You can insert the IP of your home computer.

Tom Howard
02-09-2005, 05:12 PM
one step further...

After installing awstats, I found that I wanted to restrict access, so here's what I did:

I created a password file (in a "passwords" directory that I set up)

cd /var/www/passwords

htpasswd -bc statspass.dat username password

I went to the cgi-bin directory (where awstats.pl is) and created a file named .htaccess and put in the body:

<Files awstats.pl>
AuthName "Restricted"
AuthType Basic
AuthUserFile /var/www/passwords/statspass.dat
Require valid-user
</Files>


I did it this way so that awstats.pl would be the only script that was restricted.

morton
04-14-2005, 07:45 AM
Hi TOm,

Thanks for posting this. I finally got the awstats set up after using few hours. Totally a newbie to all this and this thread really helps.

One question is setting up the password protected directory. I did everything u told me but still did not get any password protected thing. Will there be a pop-up window or something so that u need to insert the username and password? If so, i did not have any. Any help?

nsc
04-14-2005, 12:21 PM
You can set-up AWStats to use your VPS password by connecting via SSH to your VPS and using the commands:

cd /usr/local/awstats/wwwroot

pico .htaccess

Now you are editing an .htaccess text file in that directory, ensure its contents look like this:



<Files "awstats.pl">
AuthName "AWStats Restricted Area"
AuthType Basic
AuthUserFile /usr/local/apache/.htpasswd
require valid-user
</Files>


Now press CTRL+O and ENTER to save the file and then press CTRL+X to exit.

You may need to configure something in your AWStats configuration file, too, but I don't remember exactly what.

nsc
04-14-2005, 12:33 PM
I found out that I can get more updated and better statistics if I configure Cron to run AWStats every X minutes instead of every day.

This is what I did:

Login via SSH to the VPS. Type: crontab -e

If you already have an AWStats line in your cron config, change it to look like this:



1,20,40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file


The -config part must of course be customised for your particular domain or config file. Mine is "wikinerds.org" but yours may be anything depending what you typed during the AWStats installation.

The important stuff is 1,20,40. It means "run AWStats every 20 minutes at XX:01, XX:20, XX:40).

You could also type 1,30 to run it every 30 minutes.

Don't make AWStats to run too often so that you don't place too much load on your VPS. i think 20-30 mins is just fine.

morton
04-14-2005, 01:37 PM
Hey nsc, sorry for the confusion. I thought this thread was posted by the same person.


I found out that I can get more updated and better statistics if I configure Cron to run AWStats every X minutes instead of every day.

What do u mean by more updated? i have the update now setting activated. Doesnt it i can update for the latest statistics?
If i do the cron job, i will get more detailed? i do not understand. :( [/quote]

racerx_is_alive
04-15-2005, 03:54 PM
I recently installed AWStats on my server, but was having problems getting it the cron working to update it regularly. I just thought it would be a good idea to pass on what I learned from support.

1) Apparently the kernel they have doesn't support the comma syntax. So my 1,30 * * * * wasn't going through.
2) When I first typed in crontab -e, my editor in /.bashrc was not yet set to vi. So it opened the crontab file with pico. I added the appropriate line to the crontab, but when I saved it with pico, it added a carriage return where the screen had wrapped the long line. I didn't notice that there was a carriage return, because I never resized my ssh window.

So if you are having problems, check those things. Make sure you set your default editor to vi, and that 2nd problem will never be a problem.

morton
04-16-2005, 03:26 AM
1,20,40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file

This code is not working for me. Or maybe i do not understand the part where to change it. I am using putty. and when i was logged in, i typed crontab -e
then 1,20,40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=awstats.mydomain.com.conf

but it says error bad month or bad day and error in config file.

Any help?

wildjokerdesign
04-16-2005, 06:59 AM
I think it may have something to do with what racerx_is_alive mentioned in the post above yours. He mentioned that with the way WH has things set up you can't use commas so the start of your cron entry would be 1 20 40 * * * * just removed the commas from what you did.

morton
04-16-2005, 08:58 AM
Thanks for replying

Still, the error exists without the ,. It still says "/tmp/mylogin":2 bad-day-of-month
errors in crontab file, can't install.

And then it pops out to command line. :(

torrin
04-16-2005, 09:09 AM
If the comma syntax doesn't work, do it with 3 lines instead of 1.


1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file
40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file

morton
04-16-2005, 05:19 PM
Torrin,

Thx for the comment. I guess it is working now. Although i have no idea how it works, but hope there will be no problems with my awstats. Third day after installing awstats, the first day was good, second day was totally not accurate and today is the third day. Hope its getting better.

morton
04-17-2005, 03:32 AM
SOmething is wrong with my awstats. It works for one day and the next day it is malfunctioning. Like 14 apr, i have 400 visits, then on 15 april, i will only have 61 visits. And on 16 april, i got 500 visits, and on 17 arpil, i noticed the time now is 4.30a.m but i only have 2 visits and moreover, i cannot update the stats when trying to click update now.

I am not sure what is wrong. Maybe it's my conjob? Any help pls?

jalal
04-17-2005, 05:25 PM
One thing to watch is the coordination of awstats with logrotate.

Lets say that logrotate will rotate your logs at midnight.
Then lets say you have awstats set to update its records at 1 am.

Now there will come times when logrotate will rotate the log file and awstats will be faced with a (nearly) empty one. A days records will have disappeared.
On a busy site where the logs get rotated every 2/3 days then that can make quite a difference.

So make sure that awstats runs just before logrotate does its stuff.
You can also add the awstats command into the logrotate scripts so that when logrotate does a rotation it will call awstats before it does that.
There is thread around here which discussed this about a month ago I think.

morton
04-19-2005, 02:34 AM
Please help me with the code below found on my crontab -e


0 1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=mydomain.com.com
1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=awstats.mydomain.com.conf
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf
40 * * * *
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl-update-config=mydomain.com.conf
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

I have no idea how this code works. I just followed all the intructions given and typed everything into the crontab -e

Is this code wrong? My stats are not accurate at all. :(

jalal
04-19-2005, 02:38 AM
What is the crontab -e?

I don't have one on my server.

morton
04-19-2005, 03:40 AM
First, it couldn't create a crontab entry, so I had to make one. I typed this to open the cron editor: crontab -e

Then in my cron file I inserted a new line at the very top. The line looks like this for my setup: 0 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=wikinerds.org


I was just following the instructions listed. I am using Putty and when i was logged on, i type crontab -e and then there were alreadt two lines there at first.


9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

then i inserted the other lines as suggested. I did something wrong? Or is there other ways to update the hour?

torrin
04-19-2005, 07:27 AM
0 1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=mydomain.com.com
1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=awstats.mydomain.com.conf
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf
40 * * * *
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl-update-config=mydomain.com.conf
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

I really have no idea about updating stats with awstats (I don't use it), but I can help with the crontab file. Did you notice that on the first line you have 6 entries than the command. That should only be 5 entries then the command. Also, should that last part on the line be conf, not com. Is there supposed to be a space between -update and -config? I recommend you change it to . . .
0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=mydomain.com.conf The second line references awstats.mydomain.com.conf instead of mydomain.com.conf. Is that intentional? On the 40 line, should there be a space between awstats.pl and -update?

Just as a side note, I actually don't know which is right, space or no space. Check your documentation or try running the command on the command line and see if it works. If it doesn't work on the command line, it probably won't work in your crontab either. Maybe somebody here that is more familiar with awstats can jump in on this one.

By the way, for those who don't know, those entries are . . .

minute
hour
day of month
month
day of week
command

The last command given in the example code means run that wusage command at 2:14 AM everyday.

morton
04-19-2005, 08:48 AM
Thanks for replying. I decided to use only this code in my crontab -e


0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

Hope it will go well. :)

morton
05-26-2005, 12:50 AM
Ok, guess my crontab -e is still NOT working well. I have to check my stats frequently to get the correct results. Here is my crontab file:-

1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf
40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
-update-config=mydomain.com.conf


Anyone can help me out? This thing has bothered me for weeks. If anyone has successfuly installed awstats and found your crontab working good, please share your file here. THANKS!

jalal
05-26-2005, 03:03 AM
1. You need to make sure that the lines don't wrap.
2. You need a space between -update and -config
3. Don't put conf on the end of the filename


1 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com

HTH

morton
05-26-2005, 03:20 AM
Thanks for the space tips. But now it says error in minute, or hours, or bad day of month. Cant' install. God this is irritating. Here is the "latest" code now. Anything wrong with this?

1 20 40 * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl
-update -config=mydomain.com

It is still error cant install. But when i type crontab -e now, it shows this. So i am not sure whether this is working now or not.

Jalal:-

1 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl
-update -config=mydomain.com

means running the crontab every minute right? Will that be too much? Or am i wrong?

Thanks for any help.

torrin
05-26-2005, 08:11 AM
Anything wrong with this?

1 20 40 * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com

You had it more correct before. Put them on different lines. Here is an example . . .


0 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com
20 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com
40 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com


1 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl
-update -config=mydomain.com

means running the crontab every minute right? Will that be too much? Or am i wrong?

That line means run it when ever the minute is equal to one. In other words, 10:01, 11:01, 12:01, 13:01, 14:01, 15:01, 16:01, etc.

morton
05-26-2005, 11:27 AM
Thanks Torrin! Appreciate it. By the way, here is ly "latest" crontab now:-


0 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com
20 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com
40 * * * * /usrlocal/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

Do you guys think that it is because of the logrotate timing? The logrotate runs like this?
every 9 minutes, and every 0 hour? I am confused with this. :(

torrin
05-26-2005, 11:44 AM
Oops, I put down
/usrlocal instead of
/usr/local. You probably already saw this, but just in case you didn't, you might want to make sure you have the correct path. From your eariler posts, I assume it should be
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl.



9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null

Do you guys think that it is because of the logrotate timing? The logrotate runs like this?
every 9 minutes, and every 0 hour? I am confused with this. :(

As for the meaning of the logrotate line. It means run whenever the minute equals 9 and the hour equals 0. So at 00:09 every day, it will run. So yes, since awstats needs the logs to operate and logrotate will move them, yes it will interfere. From what I can tell, you'll lose 9 minutes of logs. The 9 minutes will be from 00:00 (when awstats will run) to 00:09 (when logrotate will run) every day. You can avoid this by modifying the logrotate.conf file to run awstats before rotating. There is another post about that on the forum. Let me see if I can find it.

torrin
05-26-2005, 12:02 PM
http://forums.westhost.com/phpBB2/viewtopic.php?t=2842

This topic mentions how to do it.

morton
05-26-2005, 12:39 PM
Thanks for the effore Torrin. But i can't understand much about that thread. Anyway, 9 mins is not a big deal to me. Losing 9 mins in statistics doesnt make much difference. Just that at least the other 23 hours and 51 mins will work well. :>

Yea i have changed the usr/local/

Thanks!

morton
05-28-2005, 02:43 AM
Ok. the code is still not working. Very dissapointing. Here are my steps to set up cronjob. Please correct me if wrong.

1)open putty
2)login as mydomain.com
3)type myusername
4)type mypassword
5)type crontab -e
6)code for crontab job

0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=mydomain.com
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=mydomain.com
40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=mydomain.com
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/omyusername/.wusage/wusage.conf > /dev/null

7)if i ever did any changes, i will use ctrl x, then type y for save buffer.
i did a change to mydomain name from mydomain.com to www.mydomain.com
9)so now here is my newest code
10)

0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=www.mydomain.com
20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=www.mydomain.com
40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update
-config=www.mydomain.com
9 0 * * * /bin/logrotate /etc/logrotate.conf 2>&1 > /dev/null
14 2 * * * /usr/home/myusername/wusage8.0/wusage -c /usr/home/myusername/.wusage/wusage.conf > /dev/null

11) PLEASE, anyone with a working awstats who will update the stats itself, post here your crontab job. VERY VERY appreciate.
12) I found this not working because usually i will check stats every few hours each day. But if i did not check the stats accessing from my browser and wait for 18+ hours, the stats are totally wrong. I purposely do not want to check the stats to make sure the awstats is working fine. But to my dissapointment, it is not working.

:( :( :( :(

tubanewsrose
05-28-2005, 04:29 AM
Hi Morton! I was struggling with this today as well and finally got it working.

Here is my code:


9 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.tubanews.com

However, the problem wasn't my code here...but some older cron jobs that were being bumped onto two lines when I added the code above, they were giving the errors. Paste that in and then go carefully through all the lines and make sure they don't wrap to two. It should look like this at the end, cut off with the $ sign


9 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.tub$

any luck?

morton
05-28-2005, 02:15 PM
9 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.tub$

What is this code suppose to mean? So if your domain name is tubanews.com, you substitute with www.tub$? i dont understand at all. Please explain. :(

wildjokerdesign
05-28-2005, 09:47 PM
I think tubanewsrose was saying that is what it would look like if it the line wrapped and it was wrong. At least that is how I read it. Pretty sure you need to entire domain that you are getting results for.

Reuben
10-24-2005, 08:20 PM
After too many frustrating hours attemptng to get this running on one of many sites I need to install it on, I've come to the conclusion it would be faster to hire somebody to do it. Anyone willing?

reuben@clearcreekstudios.com

Leigh
11-05-2005, 12:17 AM
I want to be able to access AWstats in a browser, like I can with CPanel. I decided to give the installation a try. Using putty, I followed the instructions above OK (as far as I can tell).

But when I go to the AWstats URL (http://mydomain.com/awstats/awstats.pl?config=health-pad), "the page cannot be displayed"

I wondered whether I needed to to a manual -update, so with putty I tried
awstats_buildstaticpages.pl -update -config=mydomain

and got the error message bad interpreter: Permission denied

- where do I go from here? What do I need to do to be able to see the stats?

calumcoburn
03-27-2006, 11:09 AM
1,20,40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=your-domain-name-awstats-config-file

This code is not working for me. Or maybe i do not understand the part where to change it. I am using putty. and when i was logged in, i typed crontab -e
then 1,20,40 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=awstats.mydomain.com.conf

but it says error bad month or bad day and error in config file.

Any help?

Looks like you're trying to run it at every 20 minutes. Do try with the following entry in your crontab it will work


*/20 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=awstats.mydomain.com.conf

Jonnyb0y
04-20-2006, 10:37 AM
For all of you AWStats users-- a minor security alert was issued:

http://secunia.com/advisories/19725/

The impact is pretty minor. A malicious person can't use it to get access to your account (unlike previous vulnerabilities it has had).

Hope this helps!

WestHost - BErickson
05-12-2006, 04:11 PM
AWStats has been added as a Site Application (for automatic installation). By the end of next week, clients with plans supporting web stats will see it in their control panels (Site Manager).