Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configure AWstats log analysis software

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Requirement description

After building the server, the administrator should make continuous analysis and adjustment to the performance of the website in the later stage, so as to achieve the most perfect state. The daily log visits, peak hours, stress and so on of the server are analyzed by the log information system. If there is no estimate in advance, the corresponding cpu and memory are not given. If one day suddenly high value, the server will crash directly. Through the observation of the log, in order to put forward the rectification plan in the future work adjustment.

Brief introduction

In the httpd server access log file access_log, a large number of client access information is recorded. Through the analysis of these information, we can know the access situation of the Web site in time, and through the AWStats log analysis system, we can complete the automatic log analysis and statistics work. The AWStats log analysis system can be used to analyze the access log information of Apache, Samba, Vsftpd, IIs and other servers.

Experimental environment

System environment: centos7 64

Server ip address: 192.168.40.15

Build steps:

I. preparatory work

1. Turn off the firewall and selinux

[root@localhost ~] # systemctl stop firewalld

[root@localhost ~] # vi / etc/sysconfig/selinux

[root@localhost ~] # reboot # restart Linux takes effect

Second, set up httpd service

[root@localhost ~] # yum-y install httpd

[root@localhost ~] # vim / etc/httpd/conf/httpd.conf # modify the main configuration file

[root@localhost ~] # systemctl start httpd # start the httpd service

[root@localhost ~] # echo "Hello everyone" > / usr/local/httpd/htdocs/index.html # sets the default home page

Test page

Third, build AWStats log analysis system.

1. Configure AWstats log analysis software

Apachectl-D DUMP_MODULES | grep cgi / / confirm that the cgi module is loaded

Ls / usr/local/httpd/modules/ | grep cgi / / confirm whether the cgi module has been compiled

Vi / usr/local/httpd/conf/httpd.conf / / manually load

LoadModule cgid_module modules/mod_cgid.so

LoadModule cgi_module modules/mod_cgi.so

2. Upload or install AWStats software package

[root@localhost ~] # tar xf awstats-7.6.tar.gz

[root@localhost ~] # mv awstats-7.6 / usr/local/awstats # cut the source code to the / usr/local directory

[root@localhost ~] # cd / usr/local/awstats/tools/

[root@localhost ~] # chmod + x awstats_configure.pl # gives execution permission to the configuration script

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

-AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur-

This tool will help you to configure AWStats to analyze statistics for

One web server. You can try to use it to let it do all that is possible

In AWStats setup, however following the step by step manual setup

Documentation (docs/index.html) is often a better idea. Above all if:

You are not an administrator user,You want to analyze downloaded log files without web server,You want to analyze mail or ftp log files instead of web log files,You need to analyze load balanced servers log files,You want to 'understand' all possible ways to use AWStats...

Read the AWStats documentation (docs/index.html).

-> Running OS detected: Linux, BSD or Unix

-> Check for web server install

Enter full config file path of your Web server.

Example: / etc/httpd/httpd.conf

Example: / usr/local/apache2/conf/httpd.conf

Example: C:\ Program files\ apache group\ apache\ conf\ httpd.conf

Config file path ('none' to skip web server setup):

/ usr/local/httpd/conf/httpd.conf

# fill in the full profile path of the website server. The path here is / usr/local/httpd/conf/httpd.conf

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

Warning: You Apache config file contains directives 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 [ymob N]? Y

# convert the log format to combined to show more details

Add 'Alias / awstatsclasses "/ usr/local/awstats/wwwroot/classes/"'

Add 'Alias / awstatscss "/ usr/local/awstats/wwwroot/css/"'

Add 'Alias / awstatsicons "/ usr/local/awstats/wwwroot/icon/"'

Add 'ScriptAlias / awstats/ "/ usr/local/awstats/wwwroot/cgi-bin/"'

Add''directive

AWStats directives added to Apache config file.

-> Update model config file'/ usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'

File awstats.model.conf updated.

-> Need to create a new config file?

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

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

# whether you need to create a configuration file for AWStats, of course "y"

-> 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.ly.com # specifies the target site name, virtual host name or custom configuration name to be counted, which can support multiple sites for observation at the same time.

-> 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):

# enter by default, and define the configuration file path in the / etc/awstats directory

-> Create config file'/ etc/awstats/awstats.www.ly.com.conf'

Config file / etc/awstats/awstats.www.ly.com.conf created.

-> Restart Web server with'/ sbin/service httpd restart'

-> 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.ly.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...

A SIMPLE config file has been created: / etc/awstats/awstats.www.ly.com.conf

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

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

Perl awstats.pl-update-config=www.ly.com

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

Http://localhost/awstats/awstats.pl?config=www.ly.com # pay attention to visiting the URL of awstats

Press ENTER to finish... # enter to exit by default

3. Modify awstats configuration file

[root@localhost ~] # vi awstats/awstats.www.ly.com.conf / / modify the main configuration file of the program

LogFile= "/ usr/local/httpd/logs/access_log" / / LogFile is used to specify the log file location, line 50

DirData= "/ var/lib/awstats" / / 220lines manually establish the data storage location for each crawl

[root@localhost ~] # mkdir / var/lib/awstats # create a directory for storing awstats statistics

4. Clear the previously modified log format

[root@localhost ~] # cd / usr/local/httpd/logs/

[root@localhost logs] # rm-f * log # used to be common, but now it has been changed to combined using awstats

[root@localhost logs] # service httpd restart # regenerate log files

5. Collect data and visit awstats

[root@localhost ~] # cd / usr/local/awstats/tools/

[root@localhost tools] # chmod + x awstats_updateall.pl

[root@localhost tools] #. / awstats_updateall.pl now / / collect / follow the new data manually

Next, visit the next page.

Manual collection again

Http://192.168.40.15/awstats/awstats.pl?config=www.ly.com

6. it is not convenient to follow the new manual, with the help of scheduled task execution:

[root@localhost tools] # crontab-e # Edit recurring task schedule

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

Crontab-l

Service crond status

Systemctl enable crond

Systemctl list-unit-files | grep crond

7. Optimize the access to the statistics page by automatically redirecting the configuration page

[root@localhost ~] # vi / usr/local/httpd/htdocs/aw.html # create a jump page

8. Set awstats web page access authentication

[root@localhost ~] # vim / usr/local/httpd/conf/httpd.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report