Apache与AWStats

一、           实验步骤及结果

第一阶段

                                                 搭建Apache网站服务

 


Hstname


OS


IP


Software


www.benet.com


CentOS-6.5


192.168.1.200


httpd-2.2.17.tar.gz

awstats-7.0.zip


Client


Windows 7


192.168.1.234


IE

 

关闭防火墙:service iptables stop

配置Apache服务

[[email protected] /]# tar zxvf httpd-2.2.17.tar.gz -C /usr/src/

[[email protected] /]# unzip awstats-7.0.zip

[[email protected] /]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi && make && make install

--prefix:指定安装目录

--enable-so:启用动态加载模块支持

--enable-rewrite:启用网站重写功能

--enable-charset-lite:启动字符集支持

--enable-cgi:启用CGI脚本程序支持

[[email protected] httpd-2.2.17]# ln -s /usr/local/httpd/bin/* /usr/local/bin/               //优化执行路径

[[email protected] ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

[[email protected] ~]# vim /etc/init.d/httpd

#chkconfig: 35 85 15

#description: Apache HTTP Server

[[email protected] ~]# chkconfig --add httpd

[[email protected] ~]# chkconfig --level 35 httpd on

[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf

ServerName www.benet.com:80                               //添加网站域名

[[email protected] ~]# httpd –t                                                //检查配置文件错误

Syntax OK

[[email protected] ~]# /etc/init.d/httpd start

[[email protected] ~]# netstat -anpt |grep 80

tcp        0      0 :::80                       :::*                        LISTEN      54881/httpd

[[email protected] ~]# elinks http://192.168.1.200

It works!

基于不同的域名创建虚拟Web主机

为两个站点创建网站的文档目录

[[email protected] ~]# mkdir /usr/local/httpd/htdocs/benetcom

[[email protected] ~]# mkdir /usr/local/httpd/htdocs/accpcom

[[email protected] ~]# echo ‘<h1>www.benet.com</h1>‘ > /usr/local/httpd/htdocs/benetcom/index.html

[[email protected] ~]# echo ‘<h1>www.accp.com</h1>‘ > /usr/local/httpd/htdocs/accpcom/index.html

修改配置文件httpd.conf和httpd-vhosts.conf

[[email protected] ~]# cd /usr/local/httpd/conf/extra/

[[email protected] extra]# vim httpd-vhosts.conf

NameVirtualHost 192.168.1.200:80

<VirtualHost 192.168.1.200:80>

DocumentRoot "/usr/local/httpd/htdocs/benetcom/"

ServerName www.benet.com

ErrorLog "logs/www.benet.com-error_log"

CustomLog "logs/www.benet.com-access_log" common

</VirtualHost>

<VirtualHost 192.168.1.200:80>

DocumentRoot "/usr/local/httpd/htdocs/accpcom/"

ServerName www.accp.com

ErrorLog "logs/www.accp.com-error_log"

CustomLog "logs/www.accp.com-access_log" common

</VirtualHost>

[[email protected] extra]# cd ..

[[email protected] conf]# vim httpd.conf

Include conf/extra/httpd-vhosts.conf                          //将此行前面的"#"去掉

[[email protected] ~]# vim /etc/hosts

192.168.1.200   www.benet.com www.accp.com

[[email protected] ~]# /etc/init.d/httpd restart

[[email protected] ~]# elinks http://www.benet.com

www.benet.com

[[email protected] ~]# elinks http://www.accp.com

www.accp.com

第二阶段

部署安装awstats日志分析系统

[[email protected] /]# unzip awstats-7.0.zip

[[email protected] /]# mv awstats-7.0 /usr/local/awstats

[[email protected] /]# cd /usr/local/awstats/tools/

[[email protected] tools]# ./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

-----> 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):

> /usr/local/httpd/conf/httpd.conf                       //httpd主配置文件路径

-----> Check and complete web server config file ‘/usr/local/httpd/conf/httpd.conf‘

Warning: You Apache config file contains directives to write ‘common‘ log files

This means that some features can‘t work (os, browsers and keywords detection).

Do you want me to setup Apache to write ‘combined‘ log files [y/N] ? y           //设置日志文件类型

Add ‘Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"‘

Add ‘Alias /awstatscss "/usr/local/awstats/wwwroot/css/"‘

Add ‘Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"‘

Add ‘ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"‘

Add ‘<Directory>‘ directive

AWStats directives added to Apache config file.

-----> Update model config file ‘/usr/local/awstats/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.benet.com                                                          //统计的站点名称

往后默认配置按回车

修改awstats.www.benet.com.conf配置文件

[[email protected] ~]# mkdir /var/lib/awstats

[[email protected] ~]# vim /etc/awstats/awstats.www.benet.com.conf

LogFile="/usr/local/httpd/logs/access_log"

DirData="/var/lib/awstats"

创建数据库的存放目录,并更新数据库

[[email protected] ~]# /usr/local/awstats/tools/awstats_updateall.pl now                   //执行更新脚本

Running ‘"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.benet.com -configdir="/etc/awstats"‘ to update config www.benet.com

Create/Update database for config "/etc/awstats/awstats.www.benet.com.conf" by AWStats version 7.0 (build 1.971)

From data in log file "/usr/local/httpd/logs/access_log"...

Phase 1 : First bypass old records, searching new record...

Searching new records from beginning of log file...

Jumped lines in file: 0

Parsed lines in file: 2

Found 0 dropped records,

Found 0 comments,

Found 0 blank records,

Found 2 corrupted records,

Found 0 old records,

Found 0 new qualified records.

创建周期性计划任务

[[email protected] ~]# crontab -e

*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now

创建网站跳转页

[[email protected] /] vim aws.html

<html>

<head>

<meta http-equiv=refresh content="0;

url=http://www.benet.com/awstats/awstats.pl?config=www.benet.com">

</head>

<body><body>

</html>

[[email protected] /]# mv aws.html /usr/local/httpd/htdocs/         //将跳转页移动到网站根目录下

[[email protected] ~]# /etc/init.d/httpd restart

重启apache访问awstats主页

第三阶段

为AWSstats进行访问权限的控制

客户机地址限制

[[email protected] /]# vim /usr/local/httpd/conf/httpd.conf

<Directory "/usr/local/awstats/wwwroot">

Options None

AllowOverride None

Order deny,allow

Deny from 192.168.1.234                          //拒绝IP为192.168.1.234的主机访问

</Directory>

[[email protected] /]# /etc/init.d/httpd restart

此时192.168.1.234客户机将无法访问www.benet.com/aws.html

用户身份认证限制

首先使用htpasswd工具创建用户认证数据文件

[[email protected] /]# htpasswd -c /usr/local/httpd/conf/.awspwd xuhao

New password:

Re-type new password:

Adding password for user xuhao

[[email protected] /]# cat /usr/local/httpd/conf/.awspwd

xuhao:eE3EHFDzN4A5c

修改httpd.conf配置文件,添加用户授权

[[email protected] /]# vim /usr/local/httpd/conf/httpd.conf

<Directory "/usr/local/awstats/wwwroot">

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "AWStats Directory"                        //定义受保护的领域名称

AuthType Basic                                                //设置认证的类型

AuthUserFile /usr/local/httpd/conf/.awspwd        //设置用于保存用户账号、密码文件的路径

require valid-user                                             //合法用户才能访问

</Directory>

[[email protected] /]# /etc/init.d/httpd restart

登录客户端访问测试

时间: 2024-10-27 12:59:45

Apache与AWStats的相关文章

Apache服务AWStats分析系统

一.Apache部署AWStats分析系统 搭建AWStats系统(所用软件awstats-7.0.zip ) 解压 unzip awstats-7.0.zip 移动到httpd的安装目录下 mv awstats-7.0 /usr/local/awstats cd /usr/local/awstats/tools/ chmod +x awstats_configure.pl ./awstats_configure.pl 2.建立统计站点的配置文件 Do you want me to setup

非手工编译apache中awstats日志分析管理

非手工编译apache中awstats日志分析管理 实验环境:一台linux6.5 宿主机或者虚拟win7 使用的包为awstats-7.6.tar 事先设置好域名以及DNS地址解析 博主的域名为www.abc.com 1.挂载移动 2.进行脚本的配置,有y的y,该回车的回车,需要填写的内容如下 3.进入自动生成的文件中修改 4.创建目录 5.登陆apache网页以及日志管理网页,刷新awstats管理日志 6.刷新awstats管理日志后也刷新网页 末:代码脚本记录 配置apache网站设置d

Linux Apache 给 awstats 创建 访问密码

CentOS7 安装最新版本 awstats ,在httpd.conf 中加入了alias,可以直接访问网址就进入 浏览.十分不安全. 给访问加上密码的方法: [[email protected] wwwroot]# htpasswd -bc /home/awstats/wwwroot/.htpasswd aaa 123456 [[email protected] wwwroot]# nano /etc/httpd/conf/httpd.conf #修改 Apache 配置文件,给awstats

Linux Apache 给 awstats 创建 訪问password

CentOS7 安装最新版本号 awstats ,在httpd.conf 中增加了alias,能够直接訪问网址就进入 浏览.十分不安全. 给訪问加上password的方法: [[email protected] wwwroot]# htpasswd -bc /home/awstats/wwwroot/.htpasswd aaa 123456 [[email protected] wwwroot]# nano /etc/httpd/conf/httpd.conf #改动 Apache 配置文件.给

windows下安装awstats来分析apache的访问日志

一.啰嗦两句 之前在Windows下用Apache时,也曾经配置过Awstats,然后换了工作,改用Linux+nginx,渐渐把Apache忘记了.又换了工作,又得用Apache,这回版本更新到2.4了,配置稍微有点不同,其他文章再列出了.网站上线了好几个月,因为一直没有什么流量且自己忙于各种琐屑的工作,一直没给Apache加上Awstats进行日志分析.最近网站几次搞活动,懂不懂就访问缓慢,于是意识到,该加上日志分析工具了.今天趁着周末,重新来配置Awstats,感觉有点陌生.查了各种资料,

(原创)在ubuntu 14.04 中安装Apache2+modsecurity+awstats (新手教程)

最好都在root账户下安装,百度ubuntu14.04 root 就可以看到一片教程,写的很详细,很方便 安装Apache2 本次安装采用apt-get安装 apt-get install apache2 当最后面出现 * Starting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set

Apache日志配置详解(rotatelogs LogFormat)

logs/error_logCustomLog logs/access_log common--默认为以上部分 修改为如下: ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/10.70.25.143:10002.errorlog.%Y%m%d%H 7200 480"CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/10.70.25.143:10002.accesslog.%Y%m%d%

Ubuntu 服务器中配置 AWStats

AWStats 是一个开源的网站分析报告工具,可以生成强大的网站.流媒体.FTP 或邮件服务器的访问统计图.此日志分析器以 CGI 或命令行方式进行工作,并在网页中以图表的形式尽可能的显示你日志中所有的信息.它可以"部分"读取信息文件,以便能够频繁并快速处理大量的日志文件.它支持绝大多数 Web 服务器日志文件格式,包括 Apache,IIS 等. 安装 AWStats 包 默认情况下,AWStats 的包可以在 Ubuntu 仓库中找到. 可以通过运行下面的命令来安装: sudo a

astats日志分析系统

Awstats是一个免费非常简洁而且强大有个性的网站日志分析工具. 功能: 一:访问量,访问次数,页面浏览量,点击数,数据流量等 二:精确到每月.每日.每小时的数据 三:访问者国家 四:访问者IP 五:Robots/Spiders的统计 六:访客持续时间 七:对不同Files type 的统计信息 八:Pages-URL的统计 九:访客操作系统浏览器等信息 十:其它信息(搜索关键字等等) 1.安装httpd [[email protected] /]# tar zxvf httpd-2.2.17