参考博文:
http://freeloda.blog.51cto.com/2033581/1346412
http://freeloda.blog.51cto.com/2033581/1346076
http://www.shuijingwanwq.com/2013/07/30/82/
http://os.51cto.com/art/201311/415087_all.htm
1、安装apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
yum -y
install
gcc gcc-c++ openssl-devel pcre-devel
tar
xf apr-1.4.6.
tar
.bz2
cd
apr-1.4.6
.
/configure
--prefix=
/usr/local/apr
--disable-ipv6
make
&&
make
install
tar
xf apr-util-1.4.1.
tar
.bz2
cd
apr-util-1.4.1
.
/configure
--prefix=
/usr/local/apr-util
--with-apr=
/usr/local/apr
make
&&
make
install
tar
zxf httpd-2.4.17.
tar
.gz
cd
httpd-2.4.17
.
/configure
\
--prefix=
/usr/local/apache
\
--sysconfdir=
/etc/httpd
\
--
enable
-so \
--
enable
-ssl \
--
enable
-cgi \
--
enable
-rewrite \
--with-zlib \
--with-pcre \
--with-apr=
/usr/local/apr
\
--with-apr-util=
/usr/local/apr-util
\
--
enable
-modules=most \
--
enable
-mods-shared=most \
--
enable
-mpms-shared=all \
--with-mpm=event
make
&&
make
install
cp
build
/rpm/httpd
.init
/etc/init
.d
/httpd
vim
/etc/init
.d
/httpd
httpd=${HTTPD-
/usr/local/apache/bin/httpd
}
pidfile=${PIDFILE-
/usr/local/apache/logs/
${prog}.pid}
lockfile=${LOCKFILE-
/var/lock/subsys/
${prog}}
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=
/etc/httpd/httpd
.conf
echo
"PATH=/usr/local/apache/bin:$PATH"
>>
/etc/profile
.d
/http
.sh
.
/etc/profile
.d
/http
.sh
ln
-s
/usr/local/apache/include/
/usr/include/httpd
vim
/etc/httpd/httpd
.conf
ServerName localhost:80
chkconfig --add httpd
chkconfig httpd on
service httpd start
|
2、安装日志切割工具cronolog
1
2
3
4
5
6
7
8
9
10
|
wget http:
//cronolog
.org
/download/cronolog-1
.6.2.
tar
.gz
tar
xf cronolog-1.6.2.
tar
.gz
cd
cronolog-1.6.2
.
/configure
make
&&
make
install
vim
/usr/local/httpd/httpd
.conf
CustomLog
"|/usr/local/sbin/cronolog /log/www/access_%Y%m%d.log"
mkdir
-p
/log/www
chmod
-R 755
/log/www/
chown
-R daemon
/log/www/
|
3、安装awstats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
tar
zxf awstats-7.4.
tar
.gz
mv
awstats-7.4
/usr/local/awstats
cd
/usr/local/awstats/
chown
-R root.root
/usr/local/awstats
chmod
+x
/usr/local/awstats/wwwroot/cgi-bin/
*.pl
cd
/usr/local/awstats/tools/
.
/awstats_configure
.pl
> perl awstats.pl -update -config=www.
test
.com
vim
/etc/awstats/awstats
.www.
test
.com.conf
LogFile=
"/log/www/access_%YYYY-24%MM-24%DD-24.log"
#日志文件存放路径,其中%YYYY-24%MM-24%DD是指年月日模式
DirData=
"/var/lib/awstats"
#创建生成的数据路径
Lang=
"cn"
#默认语言中文
SkipHosts=
"127.0.0.1 REGEX[^192\.168\.]"
#本地及内部的访问不做分析统计
LevelForWormsDetection=2
#日志等级,不对警告日志进行统计
mkdir
-pv
/var/lib/awstats
chmod
755
/var/lib/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats
.pl -update -config=www.
test
.com
vim
/etc/httpd/httpd
.conf
<IfModule !mpm_prefork_module>
LoadModule cgid_module modules
/mod_cgid
.so
<
/IfModule
>
<Directory
"/usr/local/awstats/wwwroot"
>
Options None
AllowOverride None
Require all granted
Order allow,deny
Allow from 192.168.100.1
<
/Directory
>
service httpd restart
|
4、设置定时生成静态awstat数据
1
2
|
crontab
-u root -e
5 0 * * *
/usr/local/awstats/wwwroot/cgi-bin/awstats
.pl -update -config=www.
test
.com
|
5、测试
在浏览器中输入网址
http://www.test.com/awstats/awstats.pl?config=www.test.com
本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1733875,如需转载请自行联系原作者