1. ดาวน์โหลดและติดตั้ง LogZilla
- sudo su -
- cd /var/www
- wget http://php-syslog-ng.googlecode.com/files/logzilla_v2.9.9o.tgz
- tar xzvf logzilla_v2.9.9o.tgz
- mv php-syslog-ng logzilla
2.ติดตั้ง และ config syslog-ng
- aptitude install syslog-ng
แก้ไข /etc/syslog-ng/syslog-ng.conf
- options {
- long_hostnames(off);
- # doesn't actually help on Solaris, log(3) truncates at 1024 chars
- log_msg_size(8192);
- # buffer just a little for performance
- # sync(1); <- Deprecated - use flush_lines() instead
- flush_lines(1);
- # memory is cheap, buffer messages unable to write (like to loghost)
- log_fifo_size(16384);
- # Hosts we don't want syslog from
- #bad_hostname("^(ctld.|cmd|tmd|last)$");
- # The time to wait before a dead connection is reestablished (seconds)
- time_reopen(60);
- #Use DNS so that our good names are used, not hostnames
- use_dns(yes);
- dns_cache(yes);
- #Use the whole DNS name
- use_fqdn(yes);
- keep_hostname(yes);
- chain_hostnames(no);
- #Read permission for everyone
- perm(0644);
- # The default action of syslog-ng 1.6.0 is to log a STATS line
- # to the file every 10 minutes. That's pretty ugly after a while.
- # Change it to every 12 hours so you get a nice daily update of
- # # how many messages syslog-ng missed (0).
- # stats(43200);
- };
- ### Sources ###
- source s_net {
- udp(ip(0.0.0.0) port(514));
- tcp(ip(0.0.0.0) port(514) keep-alive(yes) max-connections(300));
- };
- source s_local {
- # message generated by Syslog-NG
- internal();
- # standard Linux log source (this is the default place for the syslog()
- # function to send logs to)
- unix-stream("/dev/log");
- # messages from the kernel
- file("/proc/kmsg" log_prefix("kernel: "));
- };
- ### Destinations ###
- destination d_messages { file("/var/log/messages"); };
- destination d_logzilla {
- program("/var/www/logzilla/scripts/db_insert.pl"
- template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
- );
- };
- ### Logs ###
- log {
- source(s_local);
- destination(d_messages);
- };
- log {
- source(s_local);
- source(s_net);
- destination(d_logzilla);
- };
3.ติดตั้ง Package อื่น ๆ ที่จำเป็น
- aptitude install apache2 php5 php5-gd php5-cli php5-mysql mysql-server msttcorefonts build-essential
- cpan Text::LevenshteinXS
- cpan -i Digest::SHA1
- cpan -i Net::MySQL
4.Config Apache กับ PHP
- nano /etc/php5/apache2/php.ini
- nano /etc/php5/cli/php.ini
แก้ไขให้เป็น
- memory_limit = 128M
- max_execution_time = 300
- nano /etc/apache2/conf.d/logzilla
- Alias /logs "/var/www/logzilla/html/"
- <Directory "/var/www/logzilla/html/">
- Options Indexes MultiViews FollowSymLinks
- AllowOverride All
- Order allow,deny
- Allow from all
- </Directory>
- /etc/init.d/apache2 restart
- chown -R www-data:www-data /var/www/logzilla/html
5.Logrotate
- mkdir -p /var/log/logzilla
- nano /etc/logrotate.conf
- /var/log/logzilla/*.log {
- missingok
- compress
- rotate 5
- daily
- postrotate
- /etc/init.d/syslog-ng reload > /dev/null 2>&1 || true
- endscript
- }
ตั้งเวลา
- crontab -e
- @daily php /var/www/logzilla/scripts/logrotate.php >> /var/log/logzilla/logrotate.log
- @daily find /var/www/logzilla/html/jpcache/ -atime 1 -exec rm -f '{}' ';'
- 0,5,10,15,20,25,30,35,40,45,50,55 * * * * php /var/www/logzilla/scripts/reloadcache.php >> /var/log/logzilla/reloadcache.log
- cd /var/www/logzilla/html
- chmod 777 ./config/config.php
- chmod 777 ./config
- chmod 777 ./jpcache
- touch lpd_graph.jpeg
- chmod 777 lpd_graph.jpeg
เข้าไปที่ http://server/logs แล้วทำตามขั้นตอนไปเรื่อย ๆ
step 1 ป้อนแค่รหัสผ่าน mysql ของ root อย่างอื่นปล่อยเป็น default ไว้
step 3 ตรง site url ใส่ /logs/ ตามที่ตั้งค่า apache ไว้ แล้วใส่ email กับตั้งรหัสผ่านของ admin
step 4 คลิก Install CEMDB (Cisco Error Message Database) แล้วก็ Import จนเสร็จ
เข้าไปแก้ไข path ต่าง ๆ โดยใช้ script
- cd /var/www/logzilla/scripts
- ./fixpaths.sh
No comments:
Post a Comment