ทดไว้ก่อน
more file.log | awk -F" " '{print $1}' | sort | uniq -c | sort
liingz leum ˋ( ° ▽、° ")
กันลืม!! อะไรที่มันจะลืมเอามันมาลงบล็อกก่อนลืม !!
Monday, April 20, 2015
Tuesday, May 21, 2013
Friday, July 1, 2011
dontlog ของ Apache
การไม่เก็บ Log ของ Apache โดยใช้ SetEnvIf
เว็บไซต์ บางเว็บไซต์มีการใช้รูปภาพเป็นส่วนประกอบจำนวนมาก
จำพวกไฟล์ gif jpg png css js ico เป็นต้น ทำให้ปริมาณของ Apache Log
มีจำนวนมากกกกกกกกก จนเป็นเหตุให้ผลาญ Disk เกิ๊น
การไม่เก็บ Log ของไฟล์จำพวกนี้ ก้อช่วยลดปริมาณ Log ได้มากเหมือนกัน
วิธีการดังนี้
แก้ไขไฟล์คอนฟิก ของ Apache ในส่วน vhost
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(css)|(js)|(ico)|(eot)$" dontlog
CustomLog "/var/log/www-access_log" combined env=!dontlog
หลังจากนั้น Restart Apache
Ref: http://www.howtoforge.com/setenvif_apache2
เว็บไซต์ บางเว็บไซต์มีการใช้รูปภาพเป็นส่วนประกอบจำนวนมาก
จำพวกไฟล์ gif jpg png css js ico เป็นต้น ทำให้ปริมาณของ Apache Log
มีจำนวนมากกกกกกกกก จนเป็นเหตุให้ผลาญ Disk เกิ๊น
การไม่เก็บ Log ของไฟล์จำพวกนี้ ก้อช่วยลดปริมาณ Log ได้มากเหมือนกัน
วิธีการดังนี้
แก้ไขไฟล์คอนฟิก ของ Apache ในส่วน vhost
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(css)|(js)|(ico)|(eot)$" dontlog
CustomLog "/var/log/www-access_log" combined env=!dontlog
หลังจากนั้น Restart Apache
Ref: http://www.howtoforge.com/setenvif_apache2
Wednesday, February 23, 2011
ติดตั้ง awstats บน ubuntu
ติดตั้ง awstats บน ubuntu 10.04
- ติดตั้งด้วยคำสั่ง sudo apt-get install awstats
- ตัวอย่างสร้างแสดงผลของ web server ดังนี้
sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.mydomain.conf
แก้ไขค่าคอนฟิก /etc/awstats/awstats.mydomain.conf ให้ถูกต้อง เช่น
LogFile="/var/log/apache2/access.log"
LogFormat=4
SiteDomain="your.domain"
HostAliases="localhost 127.0.0.1"
เพิ่มคอนฟิกของ apache /etc/apache2/conf.d/awstats ให้ถูกต้อง
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/<.Directory "/usr/lib/cgi-bin"> <./Directory>
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order deny,allow
AddHandler cgi-script cgi pl
Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css" - สั่งให้เริ่มประมวลผลสถิติข้อมูลด้วยคำสั่ง
sudo /usr/lib/cgi-bin/awstats.pl -config=mydomain -update
จะได้ข้อความแสดงผลว่า
Create/Update database for config "/etc/awstats/awstats.mydomain.conf" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 1223
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 1223 new qualified records.
แสดงว่า awstats ทำงานได้แล้ว ดูผลงานบนเวบได้ที่ http://your.domain/awstats/awstats.pl ต่อไปสั่งให้ระบบประมวลผลสถิติอัตโนมัติ
แก้ไขแฟ้ม /etc/cron.d/awstats ให้เป็นประมาณว่า
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=mydomain -update > /dev/null
แล้วสังให้ cron ทำงานใหม่ด้วยคำสั่ง sudo /etc/init.d/cron reload
Ref. http://opensource.cc.psu.ac.th
Wednesday, January 19, 2011
hostname in Ubuntu
การเปลี่ยนชื่อเครื่องของ Ubuntu Server
แก้ไข 2 ไฟล์ คือ
/etc/hosts และ /etc/hostname
แล้ว Restart hostname
#sudo /etc/init.d/hostname restart
หรือ Reboot เครื่องเลย
--จบ--
แก้ไข 2 ไฟล์ คือ
/etc/hosts และ /etc/hostname
แล้ว Restart hostname
#sudo /etc/init.d/hostname restart
หรือ Reboot เครื่องเลย
--จบ--
Subscribe to:
Posts (Atom)