Use awstats to analyze Web logs and http access control

Source: Internet
Author: User

1. decompress and release the awstats package, and execute the awstats_configure.pl script in the directory for installation.

[Root @ test src] # tar zxvf awstats-7.1.tar.gz-C/usr/local/

[Root @ test src] # mv/usr/local/awstats-7.1 // usr/local/awstats

[Root @ test src] # cd/usr/local/awstats/tools/

[Root @ test tools] #./awstats_configure.pl


1) Select "y" and change the log record format of the httpd service to "combined" to record more details.

-----> Check and complete web server config file '/usr/local/apache2/conf/httpd. conf'

Warning: You Apache config file contains ctictives to write 'common' log files

This means that some features can't work (OS, browsers and keywords detection ).

Do you want me to setup Apache to write 'combined' log files [y/N]? Y

2) Select "y" to create a new configuration file.

-----> Need to create a new config file?

Do you want me to build a new AWStats config/profile

File (required if first install) [y/N]? Y

3) define the target website name for log analysis, for example, www.benet.com)

-----> Define config file name to create

What is the name of your web site or profile analysis?

Example: www.mysite.com

Example: demo

Your web site, virtual server or profile name:

> Www.sn.com

4) define the storage directory of the awstats configuration file as "/etc/awstats" by default ")

-----> Define config file path

In which directory do you plan to store your config file (s )?

Default:/etc/awstats

Directory path to store config file (s) (Enter for default ):

>

5) The installation script for adding a cron scheduled task cannot be automatically added, prompting you to manually add the task. Press the return key to continue ).

-----> Add update process inside a scheduler

Sorry, configure. pl does not support automatic add to cron yet.

You can do it manually by adding the following command to your cron:

/Usr/local/awstats/wwwroot/cgi-bin/awstats. pl-update-config = www.sn.com

Or if you have several config files and prefer having only one command:

/Usr/local/awstats/tools/awstats_updateall.pl now

Press ENTER to continue...

6) Press enter to exit the installation script

A simple config file has been created:/etc/awstats/awstats.www.sn.com. conf

You shoshould have a look inside to check and change manually main parameters.

You can then manually update your statistics for 'www .sn.com 'with command:

> Perl awstats. pl-update-config = www.sn.com

You can also read your statistics for 'www .sn.com 'with URL:

> Http: // localhost/awstats. pl? Config = www.sn.com


Press ENTER to finish...


2. Modify the awstats. www. benet. conf configuration file.

[Root @ test conf] # vi/etc/awstats/awstats.www.sn.com. conf

LogFile = "/usr/local/apache2/logs/sn. access. log"


3. Create a database storage directory and update the database

[Root @ test conf] # mkdir/var/lib/awstats

[Root @ test conf] # perl/usr/local/awstats/wwwroot/cgi-bin/awstats. pl-update-config =

Www.sn.com


4. Set a cron scheduled task to regularly run the log analysis program.

[Root @ test conf] # crontab-e

**/5 *** perl/usr/local/awstats/wwwroot/cgi-bin/awstats. pl-update-config = www.sn.com

[Root @ test logs] # service crond start

[Root @ test logs] # chkconfig -- level 35 crond on


5. Visit the web site: http://www.sn.com/awstats/awstats.pl? Config = www.sn.com

6. Access Control: User-Based Access Control

(1) Add the following lines in httpd. conf:

<Directory "/usr/local/awstats/wwwroot">

......

AuthName "AWSTATS"

AuthType Basic

AuthUserFile/usr/local/awstats/wwwroot/. htpasswd

Require valid-user

</Directory>

(2) Use the htpasswd command to create the user account "awuser" and save it. in the htpasswd file,-c indicates the file to which the account is created. The "-c" option can be omitted when an account is added to an existing authentication file.

[Root @ test bin] # cd/usr/local/apache2/bin/

[Root @ test bin] #./htpasswd-c/usr/local/awstats/wwwroot/. htpasswd awuser

New password:

Re-type new password:

7. Access Control Based on Client address

Order allow, deny: allow first and then reject. By default, all client addresses that are not explicitly allowed are rejected.

Order deny, allow: deny first and then allow. By default, all client addresses that are not explicitly rejected are allowed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.