RHEL 5 services-build a web service using Apache (4) deploy an AWStats website Analysis System

Source: Internet
Author: User

In the access log file access_log of the httpd server, a large amount of client access information is recorded. By analyzing this information, you can know the access to the web site in a timely manner. However, because the access_log file records too much information, it is inconvenient to view it, so we use the AWStats analysis system to generate a graphical interface.

AWStats is an open-source log analysis tool developed using the perl language. It can not only analyze the access logs of Apache website servers, it can also be used to analyze the log information of Samba, Vsftpd, IIS, and other services. Combined with crond and other scheduled task services, you can regularly analyze the increasing log Content.

The AWStats package can be downloaded from the http://awstats.sourceforg.net website.

1. Install the AWStats Software Package

The installation of the awstats package is very simple. You only need to decompress the package and deploy it to the "/usr/local/" directory on the httpd server.

[Root @ localhost/] # unzip awstats-7.0.zip

[Root @ localhost/] # mv awstats-7.0/usr/lcoal/awstats

2. Create a configuration file for the site to be counted

When the AWStats system is used, the system supports separate statistics of log files of multiple websites. Generally, website names are used to distinguish different sites. Therefore, before performing Log File Analysis, you need to create a site statistics configuration file for each web site. The awstats_configure.pl script provided by the AWStats program can simplify the creation process.

[Root @ localhost/] # cd/usr/lcoal/awstats/tools/

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

Then, an interactive configuration process is displayed. The system environment, such as the awstats installation directory, httpd service configuration path, and log record format, is checked, and you are prompted to specify the site name, set the path of the configuration file.

1) Specify the path of the httpd main configuration file

650) this. width = 650; "style =" width: 573px; height: 391px "title =" 1.jpg" src = "http://www.bkjia.com/uploads/allimg/131228/01260Q127-0.jpg" width = "529" height = "380"/>

2) set the Log Type

Change the log record format of the httpd server to "combined". The server can record more detailed web access information in the log file. We recommend that you select "y". The script automatically modifies the log type.

650) this. width = 650; "title =" 2.jpg" src = "http://www.bkjia.com/uploads/allimg/131228/01260W236-1.jpg" width = "583" height = "96"/>

3) create a configuration file for the specified web site

Select "y" as prompted to create the site configuration file and specify the name of the target website to be counted. The default location of the site configuration file is/etc/awstats /)

650) this. width = 650; "style =" width: 589px; height: 339px "title =" 3.jpg" src = "http://www.bkjia.com/uploads/allimg/131228/01260VN1-2.jpg" width = "591" height = "371"/>

4) Subsequent Configuration

Next, the httpd service will be automatically restarted and requires support for the/etc/init. d/httpd script). Then, press the Enter key twice to exit the Configuration tool.

650) this. width = 650; "style =" width: 578px; height: 327px "title =" 4.jpg" src = "http://www.bkjia.com/uploads/allimg/131228/01260W307-3.jpg" width = "525" height = "350"/>

3. Modify the Site Statistics configuration file

After the configuration file is created for the site www.benet.com, further modification is required. The modification mainly includes specifying the web log file to be analyzed and the directory to store statistics.

[Root @ localhost/] # vim/etc/awstats/awstats.www.benet.com. conf

LogFile = "/usr/lcoal/httpd/logs/access_log" // specify the path of the web access log file

DirData = "/var/lib/awstats" // specify the statistics directory

Some content is omitted.

[Root @ localhost/] # mkdir-p/var/lib/awstats // create a directory for storing statistics

4. perform log analysis and set cron scheduled tasks.

You can use the awstats_updateall.pl script provided by AWStats to manually update log statistics for all sites.

[] Root @ localhost/] #/usr/local/awstats/tools/awstats_updateall.pl now

Because the content of web log files is constantly updated, in order to timely feedback the Website access situation, log analysis jobs need to be performed on a regular and custom basis.

[Root @ localhost/] # crontab-e // sets the scheduled task, which is updated every 5 minutes.

*/5 */usr/local/awstats/tools/awstats_updateall.pl now

[Root @ lcoalhost/] #/etc/init. d/crond start // enable the scheduled Task Service

[Root @ localhost/] # chkconfig -- level 35 crond on // set to automatically start at 35 levels

5. Access the AWStats Analysis System

Enter http://www.benet.com/awstats/awstats.pl in the browser? Config = www.benet.com to access AWStats Analysis

650) this. width = 650; "style =" width: 672px; height: pixel PX "title =" 5.jpg" src = "http://www.bkjia.com/uploads/allimg/131228/01260SE2-4.jpg" width = "668" height = "362"/>

When you access the AWStats system, you need to specify the awstats directory, script location, statistical target, and other information, which is not easy to remember and troublesome to input. To simplify the operation, you can create an automatically redirected html webpage under the web root directory.

[Root @ localhost/] # vim/usr/lcoal/httpd/htdocs/awstats.html

<Html>

<Head>

<Meta http-equiv = refresh content = "0;

Url = http://www.benet.com/awstats/awstats.pl? Config = www.benet.com ">

</Head>

<Body> </body>

</Html>

To access the service again, you only need to enter "http://www.bent.com/awstats.html#to access the awstatsanalysis system.

You may find that you do not need to provide the account and password when accessing the AWStats log analysis system. You only need to know the corresponding website to know the Website access status, this poses a security risk to the server. So what should we do? By the way, we can set user authorization restrictions for AWStats! For how to set user authorization restrictions, see RHEL service-using Apache to build a web site II) Client Access Control

To collect statistics for multiple websites, run the "awstats_configure.pl" script again to create a new configuration file.

 

This article is from the "initialize" blog, please be sure to keep this source http://cshbk.blog.51cto.com/5685776/1214571

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.