2013年12月30日 星期一

[研究] AWStats 7.2 安裝 (tgz)(CentOS 6.5 x86_64)

[研究] AWStats 7.2 安裝 (tgz)(CentOS 6.5 x86_64)

2013-12-30

參考
http://awstats.sourceforge.net/docs/awstats_setup.html

假設網站名稱為 www.shaurong.idv.tw,先在 /etc/hosts 增加 IP 和主機名稱對應
網址請依據自己情況修改相對應設定,以及輸入的命令

[root@localhost ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.128.104    www.shaurong.idv.tw

# 關閉防火牆
service iptables stop
chkconfig iptables off

# 關閉 SELinux,立刻生效 (但不保證 reboot 後)
/usr/sbin/setenforce 0

# 永久關閉 SELinux:把 /etc/selinux/config 中 SELINUX=enforcing 或 ELINUX=permissive 改為 SELINUX=disabled ( 要 reboot 後才生效)
sed -i -e "s@SELINUX=enforcing@#SELINUX=enforcing@"   /etc/selinux/config
sed -i -e "s@SELINUX=permissive@#SELINUX=permissive@"   /etc/selinux/config
sed -i -e "/SELINUX=/aSELINUX=disabled"   /etc/selinux/config

# 安裝和啟動 httpd web server
yum -y install httpd
service httpd restart

# 下載安裝 awstats
wget http://sourceforge.net/projects/awstats/files/AWStats/7.2/awstats-7.2.tar.gz/download
tar zxvf awstats-7.2.tar.gz -C /usr/local
ln -s /usr/local/awstats-7.2   /usr/local/awstats

# 執行設定

[root@localhost tools]# cd /usr/local/awstats/tools 

[root@localhost tools]# perl awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/local/awstats-7.2
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ? Y

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
  Add 'Alias /awstatsclasses "/usr/local/awstats-7.2/wwwroot/classes/"'
  Add 'Alias /awstatscss "/usr/local/awstats-7.2/wwwroot/css/"'
  Add 'Alias /awstatsicons "/usr/local/awstats-7.2/wwwroot/icon/"'
  Add 'ScriptAlias /awstats/ "/usr/local/awstats-7.2/wwwroot/cgi-bin/"'
  Add '<Directory>' directive
  AWStats directives added to Apache config file.

-----> Update model config file '/usr/local/awstats-7.2/wwwroot/cgi-bin/awstats.                                                                                                  model.conf'
  File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? Y

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.shaurong.idv.tw

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>

-----> Create config file '/etc/awstats/awstats.www.shaurong.idv.tw.conf'
 Config file /etc/awstats/awstats.www.shaurong.idv.tw.conf created.

-----> Restart Web server with '/sbin/service httpd restart'
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats-7.2/wwwroot/cgi-bin/awstats.pl -update -config=www.shaurong.idv.tw
Or if you have several config files and prefer having only one command:
/usr/local/awstats-7.2/tools/awstats_updateall.pl now
Press ENTER to continue...


A SIMPLE config file has been created: /etc/awstats/awstats.www.shaurong.idv.tw.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.shaurong.idv.tw' with comm  and:
> perl awstats.pl -update -config=www.shaurong.idv.tw
You can also read your statistics for 'www.shaurong.idv.tw' with URL:
> http://localhost/awstats/awstats.pl?config=www.shaurong.idv.tw

Press ENTER to finish...

[root@localhost tools]#

它會產生 /etc/awstats/awstats.www.shaurong.idv.tw.conf 檔案
( /etc/awstats/awstats.(網站名稱).conf )

# 設定 AWStats 抓的 log 是 access_log ( Apache Web Server log 預設的名稱)
cp /etc/awstats/awstats.www.shaurong.idv.tw.conf    /etc/awstats/awstats.www.shaurong.idv.tw.conf.bak
sed -i -e "s@mylog.log@access_log@"  /etc/awstats/awstats.www.shaurong.idv.tw.conf
sed -i -e "s@DNSLookup=2@DNSLookup=1@"  /etc/awstats/awstats.www.shaurong.idv.tw.conf

# 讓 Apache Web Server 有權限存取 AWStats 目錄
chown   -R   apache:apache    /usr/local/awstats/

# 建立 AWStats 預設需要的目錄
mkdir   /var/lib/awstats

# 重新啟動 Apache Web Server,讓剛剛修改的 /etc/httpd/conf/httpd.conf 生效
service httpd restart

# 執行一次,產生畫面
/usr/local/awstats//wwwroot/cgi-bin/awstats.pl -update  -config=www.shaurong.idv.tw

# 設定排程
echo '*/5 * * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.shaurong.idv.tw' >> /etc/crontab

# 啟動瀏覽器,瀏覽 AWStats 畫面
firefox http://localhost/awstats/awstats.pl?config=www.shaurong.idv.tw &

PS: perl awstats_configure.pl 執行時候會替 httpd.conf 增加下面內容

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats-7.2/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats-7.2/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats-7.2/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats-7.2/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats-7.2/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

(完)

參考

[研究] AWStats 7.2 安裝 (tgz)(CentOS 6.5 x86_64)
http://shaurong.blogspot.tw/2013/12/awstats-72-tgzcentos-65-x8664.html

[研究] AWStats 7.2快速安裝程式精簡版(tgz)(CentOS 6.5 x86_64)
http://shaurong.blogspot.tw/2013/12/awstats-72tgzcentos-65-x8664.html

[研究] AWStats 7.2快速安裝程式精簡版(tgz)(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19200

[研究] AWStats記錄檔分析 安裝法(Fedora 7)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14960

[研究] AWStats 快速安裝程式精簡版(tgz)(CentOS 4.4, 5.1)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=15013

[教學][研究] AWStats 快速安裝程式精簡版(Fedora 7,8,9)
http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=15015

沒有留言:

張貼留言