ติดตั้ง awstats บน ubuntu
จาก Wiki Opensource
รุ่นปรับปรุงเมื่อ 15:13, 4 พฤศจิกายน 2557 โดย Wisit.c (พูดคุย | เรื่องที่เขียน)
บันทึกนี้ปรับปรุงล่าสุดเมื่อวันที่ 29-09-2551
ดูแลโดย WIPAT
- ทดสอบกับ ubuntu 8.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"
สร้างแฟ้ม /etc/apache2/conf.d/awstats ให้มีข้อมูลว่า
Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
สั่งให้เริ่มประมวลผลสถิติข้อมูลด้วยคำสั่ง 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?config=mydomain
ต่อไปสั่งให้ระบบประมวลผลสถิติอัตโนมัติ
แก้ไขแฟ้ม /etc/cron.d/awstats ให้เป็นประมาณว่า
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=mydomain -update > /dev/null
แล้วสังให้ cron ทำงานใหม่ด้วยคำสั่ง sudo /etc/init.d/cron reload
------------------------------------------------------------------------------------------------------------------
เพิ่มเติม by wisit 4-11-57
สำหรับ ubuntu 12.04 , 14.04 ติดตั้งตามนี้ https://help.ubuntu.com/community/AWStats
ต้องการติดตั้งแบบรวดเร็ว script สำหรับ install awstats download scripts ได้ที่ ftp://ftp.psu.ac.th/pub/psu12-sritrang/download/scripts-pom/installawstats.sh
วิธีการใช้งาน
เปลี่ยนสิทธิ์เป็น root
sudo su -
download script
แล้ว run script
bash installawstats.sh
รอจนเสร็จ
ดูผลงานได้ที่ http://xx.xx.xx.xx/awstats/awstats.pl (xx.xx.xx.xx = ip server ที่ติดตั้ง awstats)
เพิ่มข้อความใน crontab -e ดังนี้<span style="color:#0000ff;"> 0 * * * * /usr/lib/cgi-bin/awstats.pl -config=xx.xx.xx.xx -update > /dev/null</span>
จบแล้วครับ
ขอบคุณครับ
รายละเอียด script#pom 4-11-57sudo apt-get install awstats -yMYIP=$(ifconfig eth0|grep -w "inet"|awk '{print $2}'|cut -d':' -f 2)FILE1=/etc/awstats/awstats.${MYIP}.confsudo cp /etc/awstats/awstats.conf $FILE1sudo sed -i '/SiteDomain=/ c SiteDomain="'${MYIP}'"' $FILE1sudo sed -i '/HostAliases=/ c HostAliases="localhost 127.0.0.1 '${MYIP}'"'sudo /usr/lib/cgi-bin/awstats.pl -config=${MYIP} -updatesudo a2enmod cgiFILE2=/etc/apache2/sites-available/000-default.conf #14.04FILE3=/etc/apache2/sites-available/default #12.04sudo cp ${FILE2} ${HOME}sudo cp ${FILE3} ${HOME}FILE4=myfile.txtsudo cat > ${FILE4} <<EOFAlias /awstatsclasses "/usr/share/awstats/lib/"Alias /awstats-icon "/usr/share/awstats/icon/"Alias /awstatscss "/usr/share/doc/awstats/examples/css"ScriptAlias /awstats/ /usr/lib/cgi-bin/Options ExecCGI -MultiViews +SymLinksIfOwnerMatchEOFfor i in ${FILE2} ${FILE3}doline1=$(grep -n '/VirtualHost' $i | cut -d\: -f1)line2=$(expr $line1 - 1)sed -i $line2' r '${FILE4} $idonesudo service apache2 restartecho "----------------------------"echo "check url http://${MYIP}/awstats/awstats.pl"echo "add to crontab => 0 * * * * /usr/lib/cgi-bin/awstats.pl -config=${MYIP} -update > /dev/null"echo "----------------------------"-------------------------------------------------------------------------------------------------------------------------------