cd /usr/local sudo unzip /tmp/awstats-7.2.zip
sudo mv awstats-7.2 awstats
2.以linode.tripresso.com為例,建立新的設定
/etc/awstats/awstats.linode.tripresso.com.conf
cd /usr/local/awstats
perl tools/awstats_configure.pl
# 根据提示依次输入
# web server config file path: none
# build a new AWStats config/profile: y
# awstats config file name: linode.tripresso.com(改成自己的网站名即可)
# awstats config file path: (不填,使用默认值/etc/awstats)
# 编辑配置文件
sudo vi /etc/awstats/awstats.linode.tripresso.com.conf
# 将LogFile改为nginx的access日志的位置
# LogFile="/var/log/nginx/access.log"
sudo chown -R nginx:nginx /usr/local/awstats/wwwroot
# 修改awstats的输出目录为/usr/local/awstats/wwwroot/output
# DirData="/usr/local/awstats/wwwroot/output"
sudo -u linode mkdir /usr/local/awstats/wwwroot/output
# 测试新生成的配置文件是否有效
sudo ./wwwroot/cgi-bin/awstats.pl -config=linode.tripresso.com
3.安裝Spawn-fcgi(要先安裝epel-release)
sudo yum install epel-release
yum update
yum -y install fcgi-devel
cd /usr/local/src/
git clone git://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure
make
make install
vim /etc/sysconfig/spawn-fcgi
# You must set some working options before the "spawn-fcgi" service will work.
# If SOCKET points to a file, then this file is cleaned up by the init script.
#
# See spawn-fcgi(1) for all possible options.
#
# Example :
#SOCKET=/var/run/php-fcgi.sock
#OPTIONS="-u apache -g apache -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
FCGI_SOCKET=/var/run/fcgiwrap.socket
FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
FCGI_USER=apache
FCGI_GROUP=apache
FCGI_EXTRA_OPTIONS="-M 0770"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"
usermod -a -G apache nginx
chkconfig spawn-fcgi on
systemctl start spawn-fcgi
現在應該可以在 /var/run/fcgiwrap.socket 找到fcgiwrap socket
5.設定權限及host
sudo chown nginx:nginx fcgiwrap.socket
vim /etc/nginx/conf.d/vhost.conf
寫入以下內容
server {
listen 80;
root /usr/local/awstats/wwwroot;
server_name awstats.atime.me;
location ~ \.pl$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
}
}
sudo service nginx reload
chmod -R 777 /usr/local/awstats/wwwroot/
補充:
更新流量分析
/usr/local/awstats/tools/awstats_updateall.pl now