2021年3月10日 星期三

[研究] AWStats 7.8 安裝 (tgz)(CentOS 8.3 x86_64)

[研究] AWStats 7.8 安裝 (tgz)(CentOS 8.3 x86_64)

2021-03-10

AWStats, 開源Web分析報告工具, Open Source Log File Analyzer, Log File Analyzer

參考
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.130    www.shaurong.idv.tw

# 關閉防火牆
su    root
#systemctl   stop   firewalld
#systemctl   disable   firewalld
#systemctl   status   firewalld
systemctl   start   firewalld
systemctl   enable   firewalld
systemctl   status   firewalld   --no-pager
firewall-cmd   --add-port={80,443}/tcp --permanent
firewall-cmd   --reload
firewall-cmd   --list-all

# 關閉 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
dnf  -y   install   httpd   perl
systemctl   restart   httpd
systemctl   enable   httpd
systemctl   status   httpd   --no-pager

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

# 執行設定

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

[root@localhost tools]# perl    /usr/local/awstats/tools/awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 20140126) (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.8
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'
  All AWStats directives are already present.

-----> Update model config file '/usr/local/awstats-7.8/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

如果沒有特別的網址,可以用 localhost

-----> 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):
> (按下 Enter)

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

-----> 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.8/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.8/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 command:
> 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

如果不只一個,改設定目錄 (不確定)
#LogFile="/var/log/httpd/mylog.log"
LogFile="/var/log/iis"

如果使用 IIS Log,這個值要要改,使用 httpd 就預設值
# Example for IIS:
# LogFormat = 2
#
#LogFormat=1
LogFormat=2


# 讓 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

# 設定排程每5分鐘更新一次
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 &

注意 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>

改成 (不然瀏覽器會看到 Forbidden 訊息)

<Directory "/usr/local/awstats-7.8/wwwroot">
#    Options None
#    AllowOverride None
#    Order allow,deny
    Require   all   granted
    Allow from all
</Directory>
Options   ExecCGI
AddHandler   cgi-script   .cgi   .pl

重新啟動 Web Server,讓新的 httpd.conf 生效 
[root@localhost ~]#  systemctl   restart   httpd

(不然瀏覽器會看到 Forbidden 訊息)

Forbidden

You don't have permission to access this resource.

(完)

參考

[研究] AWStats 7.8 安裝 (tgz)(CentOS 8.3 x86_64)
http://shaurong.blogspot.com/2021/03/awstats-78-tgzcentos-83-x8664.html

[研究] 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


沒有留言:

張貼留言