Apache configuration and application-log segmentation

1. Overview

1. Log split

1. With the increase of website visits, Apache’s single daily file will also become larger and larger by default

  • Log files take up a lot of disk space
  • Inconvenient to view related information

2. Split the log file

  • Apache comes with rotatelogs segmentation tool implementation
  • Third-party tool cronolog segmentation

2. Introduction to AWStats log analysis system

  • An open source log analysis system developed by Perl language
  • It can be used to analyze the access logs of Apache, Samba, Vsftpd, IIS and other servers
  • Combined with crond and other scheduled task services, the log content can be analyzed regularly

3. The configuration difference between rotatelogs tool and cronolog tool

1. Rotatelogs tool

ErrorLog “| /usr/sbin/rotatelogs -l logs/www.kgc.com.error_%Y%m%d.log 86400”

CustomLog “| /usr/sbin/rotatelogs -l logs/www.kgc.com.access_%Y%m%d.log 86400” combined

2. Cronolog tool

ErrorLog “| /usr/sbin/cronolog logs/www.kgc.com.error_%Y%m%d.log”

CustomLog “| /usr/sbin/cronolog logs/www.kgc.com.access_%Y%m%d.log” combined

2. Experimental steps

Experiment 1. Use of rotatelogs segmentation tool

1. Turn off the firewall

iptables -F

setenforce 0

mark

2. Install Apache service

yum install httpd -y

mark

3. Modify the configuration file

vim /etc/httpd/conf/httpd.conf

mark

mark

mark

mark

4. Test and restart the http service

httpd -t

systemctl restart httpd

mark

5. View the local log file

ls /var/log/httpd/

mark

6. Modify the system time

date -s 09/05/20 ## Modification time is September 05, 2020

ls /var/log/httpd/ ##View the list of log files in the directory

systemctl restart httpd ##Restart the service

ls /var/log/httpd/ ##View the list of new log files generated after restart

mark

Experiment 2. Visit AWStats analysis system

1. Turn off the firewall

iptables -F

setenforce 0

mark

2. Install apache service

yum install bind httpd -y

mark

3. Modify the main configuration file

vim /etc/named.conf

mark

4. Modify the regional configuration file

vim /etc/named.rfc1912.zones

mark

5. Modify the area details file

cd / var / named /

cp -p named.localhost kgc.com.zone

vim kgc.com.zone

mark

6. Start the DNS service

systemctl start named

mark

7, edit the http configuration file

vim /etc/httpd/conf/httpd.conf

mark

mark

8. Restart the http service

systemctl restart httpd

9. Create interface files

cd / var / www / html /

vim index.html

mark

10. The test domain name is successfully configured

The DNS server of the win10 host is: 192.168.235.135

Visit address: www.kgc.com

mark

11. Unzip the awstats toolkit

Upload the file awstats-7.6.tar.gz to the server directory /opt

cd / opt

tar zxvf awstats-7.6.tar.gz ##Unzip

mv awstats-7.6 /usr/local/awstats ##File translation

cd /usr/local/awstats/ ##Directory jump

ls

cd tools /

ls

mark

12. Installation

./awstats_configure.pl

/etc/httpd/conf/httpd.conf

and

www.kgc.com

Carriage return

Carriage return

mark

13, edit the configuration file

vim /etc/httpd/conf/httpd.conf

mark

14. Edit the log split configuration file

vim /etc/awstats/awstats.www.kgc.com.conf

mark

mark

15, create a directory

cd / var / lib

ls

mkdir awstats

mark

16, restart the service

systemctl restart httpd

mark

17. Access interface view

http://www.kgc.com/awstats/awstats.pl?config=www.kgc.com

mark

18. Update data

Address: www.kgc.com Refresh several times

http://www.kgc.com/awstats/awstats.pl?config=www.kgc.com ##No interface update

cd /usr/local/awstats/tools/

./awstats_updateall.pl now ##Update data

mark

19. Set planned tasks to update data

crontab -e

mark

20. Create optimized web pages

cd / var / www / html

vim aws.html

mark

21. Direct address access

http://www.kgc.com/aws.html

mark

Guess you like

Origin blog.csdn.net/weixin_39608791/article/details/107827147