Web Server Learning 3---httpd 2.4.29 log processing

Source: Internet
Author: User
Tags local time

. Rotarelogs Split Tool

If a virtual host is configured in the virtual host configuration file, it is modified in the master configuration file.

1.1 Modifying a configuration file

vi/usr/local/httpd/conf/conf.d/vhosts.conf//Modify in the virtual host configuration file

<virtualhost 192.168.80.180:80>
ServerAdmin [email protected]
documentroot/var/test1/
ServerName www.test1.com
customlog "|/usr/local/httpd/bin/rotatelogs-l logs/www.test1.com_custom_%y%m%d.log 86400" Common

Errorlog "|/usr/local/httpd/bin/rotatelogs-l logs/test1_error_%y%m%d.log 86400"
</VirtualHost>

Systemctl Restart httpd

Pass the log to the Rotatelogs tool by the pipeline----use local time, 86400 means log separation interval is 1 days, unit is seconds;

%y%m%d means to obtain the date of month;

Common and conbined are log fixed formats;

1.2 Experiments:

2.cronolog Segmentation (Third Party)

2.1 Installing the Build tool manually

Tar XF cronolog-1.6.2.tar.gz-c/opt/
Cd/opt/cronolog-1.6.2/
./configure
Make && make install

Which Cronolog

2.2 Modifying a configuration file

vi/usr/local/httpd/conf/conf.d/vhosts.conf// with the same settings as the own log split tool, just use the tool's path differently

<virtualhost 192.168.80.180:80>
ServerAdmin [email protected]
documentroot/var/test1/
ServerName www.test1.com
Customlog "| /usr/local/sbin/cronolog-l Logs/www.test1.com_custom_%y%m%d.log 86400 "combined
Errorlog "| /usr/local/sbin/cronolog-l Logs/test1_error_%y%m%d.log 86400 "
</VirtualHost>

Httpd-t

Systemctl Restart httpd

2.3 Experiments

Log format reason does not support the end to name the log in time.

3 Awstats Log Analysis

Focus on two points: 1.log file location;

2.log file is generated and selected correctly;

Preset conditions

Apachectl-d Dump_modules | grep CGI//Confirm that the CGI module is loaded

ls/usr/local/httpd/modules/| grep CGI//Verify that the CGI module has been compiled

vi/usr/local/httpd/conf/httpd.conf//Manual loading
LoadModule Cgid_module modules/mod_cgid.so
LoadModule Cgi_module modules/mod_cgi.so

1. Installation and Configuration

Tar xzvf awstats-7.6.tar.gz
MV Awstats-7.6/usr/local/awstats

cd/usr/local/awstats/tools/

./awstats_configure.pl //automatic configuration script, according to the prompt to fill

HTTP configuration file path/usr/local/httpd/conf/httpd.conf

Convert log format

At the end of the configuration will prompt the log to visit the webpage, which needs to be recorded as follows:

Http://192.168.80.180/awstats/awstats.pl?config=www.test1.com

2. Modify the Awstats configuration file

Vi/etc/awstats/awstats.www.test1.com.conf

logfile= "/usr/local/httpd/logs/test1.com-access_log"//modify log file location, line 50th, statistics log data must be written to.

Dirdata= "/var/lib/awstats"//220 line manually establish the data storage location for each fetch

Mkdir/var/lib/awstats

3. Access the Web page and manually collect the data

cd/usr/local/awstats/tools/
chmod +x awstats_updateall.pl
./awstats_updateall.pl now//Read access log, get data

Cd/var/lib/awstats//Check to see if data is collected

4. Accessing the page and optimizing

When accessing the Awstats system, it is necessary to specify directory, script location, statistic target and other information, which is not easy to remember. To simplify the operation, create an automatic jump HTML page in the Web root directory.

vi/usr/local/httpd/conf/conf.d/vhosts.conf//Set the access permissions for the directory where the Web page is located, actually set the virtual directory access rights, set permissions

<directory "/usr/local/awstats/wwwroot" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
AuthName "Www.test1.com"
AuthType Basic
Authuserfile/usr/local/httpd/user
Require Valid-user
Require all granted
</Directory>

vi/var/test1/index.html//Optimize access page

<meta http-equiv=refresh content= "0;url=http://www.test1.com/awstats/awstats.pl?config=www.test1.com" >
<body></body>

Visit page:

5. Automatic acquisition--Scheduled Tasks

Crontab-e

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

Crontab-l

Service Crond Status

Systemctl Enable Crond

Systemctl List-unit-files | grep Crond

Web Server Learning 3---httpd 2.4.29 log processing

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.