Two tools for monitoring apache logs
Apache Log Analysis Tool webalizer awstat
Prepare webalizer-2.23-05-src.tgz awstats-7.0.tar.gz Perl-5.16.3.1603.tar.gz
Install apache
[Root @ lly ~] # Mkdir/mnt/cdrom
[Root @ lly ~] # Mount/dev/cdrom/mnt/cdrom mount the optical drive
[Root @ lly ~] # Cd/mnt/cdrom/Server/
[Root @ lly Server] # rpm-ivh apr-1.2.7-11.el5_3.1.i386.rpm
[Root @ lly Server] # rpm-ivh postgresql-libs-8.1.11-1.el5_1.1.i386.rpm (apr-util belongs to this package)
[Root @ lly Server] # rpm-ivh apr-util-1.2.7-7.el5_3.2.i386.rpm
[Root @ lly Server] # rpm-ivh httpd-2.2.3-31.el5.i386.rpm (install httpd depending on the apr-1.2.7-11.el5_3.1.i386.rpm and rpm-ivh postgresql-libs-8.1.11-1.el5_1.1.i386.rpm or install with yum)
[Root @ lly Server] # service httpd start (start httpd)
Install webalizer
[Root @ lly ~] # Tar zxvf webalizer-2.23-05-src.tgz-C/usr/local/src/
[Root @ lly ~] # Cd/usr/local/src/webalizer-2.23-05/
[Root @ lly webalizer-2.23-05] # less INSTALL (view installation instructions)
[Root @ lly webalizer-2.23-05] #./configure -- sysconfdir =/etc (installed by default to the usr/local directory, indicating that the configuration file is placed in the/etc directory)
[Root @ lly webalizer-2.23-05] # make
[Root @ Lili webalizer-2.23-05] # make install
[Root @ lly webalizer-2.23-05] mkdir/var/www/html/log (create a log file, as the output directory of the webalizer analysis results, as mentioned in the script below)
Assume that the web server host name is www.test.com, the website domain name is www.test.com, And the access log is/var/log/httpd/access_log, the webalizer analysis result is output to/var/www/html/log.
Then we can create a log monitoring script.
However, webalizer generates a record only once when the script is executed. To monitor its periodic information, it is necessary to execute the scheduler task. Therefore, add the scheduler task first.
[Root @ Lili webalizer-2.23-05] cd
[Root @ lly ~] # Vi/etc/crontab
Add a directory to which you can modify the scheduled task. Here, change it to cron. web.
Monitoring every 60 minutes
[Root @ lly ~] # Mkdir/etc/cron. web (this directory is specified in the scheduled task, so you need to create it manually)
[Root @ lly ~] # Cd/etc/cron. web
[Root @ lly cron. web] # vi web
Edit monitoring log script web
[Root @ lly cron. web] # chmod a + x web (the script is an executable program and the execution permission must be granted)
[Root @ lly cron. web] #./web (you can execute it first)
[Root @ lly cron. web] # ll/var/www/html/log
Multiple files similar to the following will be generated in the log directory
Then you can enter http: // 192.168.126.129/log/in the address bar of your browser (My linux host address is 192.168.126.129) to access webalizer.
AWSTAT
Awstats is a Perl-based WEB log analysis tool. There are many introductions on the Internet, because it is developed based on perl. You must first install the perl environment in either windows or linux. Therefore, we need to install perl first.
Install perl
[Root @ lly ~] # Tar zxvf ActivePerl-5.16.3.1603-i686-linux-glibc-2.3.6-296746.tar.gz-C/usr/local/src/package to/usr/local/src/directory
[Root @ lly ~] # Cd/usr/local/src/ActivePerl-5.16.3.1603-i686-linux-glibc-2.3.6-296746/
[Root @ lly ActivePerl-5.16.3.1603-i686-linux-glibc-2.3.6-296746] #./install. sh
[Root @ lly ~] # Tar zxvf awstats-7.0.tar.gz-C/usr/local/src/
[Root @ lly ~] # Mkdir/etc/awstats is used to store the configuration file for site log analysis.
[Root @ lly ~] # Mkdir/var/lib/awstats is used to store Log Data Information
[Root @ lly ~] # Cd/usr/local/src/awstats-7.0/
[Root @ lly awstats-7.0] # cd/usr/local/src/awstats-7.0/tools/
[Root @ lly tools] # vim awstats_configure.pl
Awstats has its own configuration tool awstats_configure.pl. Open the configure. pl file and check whether the configuration of the perl runtime environment is correct.
Use perl to guide the awstats Configuration tool and perform related configuration
[Root @ lly tools] # perl awstats_configure.pl (execution)
Enter the full path of the web Server
Edit a virtual server or file name
Default Configuration File directory. Press enter to select the default directory, that is, the created/etc/awstats directory.
The awstats_configure.pl tool automatically modifies the apache configuration and/etc/awstats. index. conf file based on your selection when using the perl awstats_configure.pl command and automatically restarts the apache service.
The awstats_configure.pl tool will add the following content behind the apache configuration file:
The/etc/awstats/awstats.www.text.com. conf file is also generated based on the selected site information.
Add executable permissions for awstats. pl
[Root @ lly ~] # Cd/usr/local/src/awstats-7.0/wwwroot/cgi-bin/
[Root @ lly cgi-bin] # chmod + x awstats. pl
[Root @ lly cgi-bin] #/usr/local/src/awstats-7.0/tools/awstats_updateall.pl now
Or [root @ lly cgi-bin] #/usr/local/awstats-7.0/wwwroot/cgi-bin/awstats. pl-update-config = www.text.com
Enter http: // 192.168.126.129/awstats. pl? Config = www.test.com
Accessible
This article is from the "HWOTT" blog, please be sure to keep this source http://iceblock.blog.51cto.com/6758400/1182473