lygyh9985825 发表于 2019-1-30 08:29:18

http配置安装和部署Awstats统计Http访问日志

  实验一:基本HTTP服务器的配置
      主机名设为:www.tarena.com192.168.10.10
      默认首页包括:index.html、index.php
      开启保持连接
      确认默认httpd是否支持php
  前提条件在客户端配置hosts文件
  192.168.10.10www.tarena.comwww
  图(1)
  1、软件包的安装
  # rpm -q httpd
  httpd-2.2.3-74.el5
  //如果没有安装
  # yum -y install httpd
  2、修改主配置文件
  

  # vim /etc/httpd/conf/httpd.conf
  ...
  74 KeepAlive On    //开启保持连接
  ...
  265 ServerName www.tarena.com:80   //主机名设为:www.tarena.com
  ...
  391 DirectoryIndex index.html index.php// index.html、index.php
  ...
  3、启动服务
  # service httpd restart
  # chkconfig httpd on
  新建测试页面
  # cat /var/www/html/index.html
  www "welcome to the"com      //随意写入
  # cat /var/www/html/index.php
  
  Win7测试:
  http://www.tarena.com
  

  图(2)
  http://www.tarena.com/index.php
  图(2)
  

  图(3)
  在linux上测试
  

  图(4)
  

  图(5)
  

  

  

  

  

  

  

  

  

  

  

  

  

  实验二:HTTP的访问控制
  只允许192.168.1.2也就是win7系统客户端访问www.tarena.com
  允许所有用户访问www.tarena.com/authdir/index.html
  前提条件在客户端配置hosts文件
  192.168.10.10www.tarena.comwww
  1、软件包的安装
  # rpm -q httpd
  httpd-2.2.3-74.el5
  //如果没有安装
  # yum -y install httpd
  2、修改主配置文件
  # mkdir /var/www/html/authdir//创建文件夹
  # vim /var/www/html/authdir/index.html
  
  This is a test Page!!!
  
  This is http://www.tarena.com/authdir/index.html!!!
  
  
  
  # vim /etc/httpd/conf/httpd.conf
  ...
  306
  ...
  332   Order allow,deny
  333 #    Allow from all
  334   Allow from 192.168.10.5
  ...
  337
  338         Order allow,deny
  339         Allow from all
  340
  3、启动服务
  # service httpd restart
  4、在不同客户端测试
  Win7上测试
  

  图(6)
  

  图(7)
  在linux上测试
  

  图(8)
  Linux没有权限
  

  图(9)
  访问www.tarena.com/authdir/index.html成功
  

  

  

  试验三:HTTP的用户授权
  客户端访问/var/www/html/authdir/需要输入用户名密码验证
  1、软件包的安装
  # rpm -q httpd
  httpd-2.2.3-74.el5
  //如果没有安装
  # yum -y install httpd
  2、修改主配置文件
  # vim /etc/httpd/conf/httpd.conf
  ...
  337
  338         Order allow,deny
  339         Allow from all
  340         AuthName "Please Input Password!!"
  341         AuthType Basic
  342         AuthUserFile "/etc/httpd/.vuser"
  343         Require valid-user
  344
  ...
  2、创建账户密码
  # htpasswd -c /etc/httpd/.vuser admin
  New password:
  Re-type new password:
  Adding password for user admin
  3、启动服务测试
  # service httpd restart
  4、在客户机上测试
  Win7
  http://www.tarena.com/authdir
  

  图(10)
  

  图(11)
  实验四:HTTP目录别名
  要求:
  客户端访问http://www.tarena.com/sina时可以访问/var/www/html/sina.com/bbs下的网页
  1、创建测试站点
  # mkdir -p /var/www/html/sina.com/bbs
  # cat /var/www/html/sina.com/bbs/index.html
  
  This is a test Page!!!
  
  This is bbs.sina.com test Page!!!
  
  
  
  2、修改主配置文件
  # tail -n 1 /etc/httpd/conf/httpd.conf
  Alias /sina   "/var/www/html/sina.com/bbs"
  3、启动服务测试
  # service httpd restart
  http://www.tarena.com/sina
  4、在客户端测试
  在win7上
  

  图(12)
  实验五:
  部署Awstats统计Http访问日志
  1、安装软件(软件在/usr/src下)
  # cd /usr/src/
  # tar -zxf awstats-7.1.tar.gz
  # mv awstats-7.1 /usr/local/awstats
  2、为站点建立配置文件
  # cd /usr/local/awstats/tools/
  # ./awstats_configure.pl
  ...
  Config file path ('none' to skip web server setup):
  > /etc/httpd/conf/httpd.conf    //输入apache的主配置文件
  ...
  -----> Need to create a new config file ?
  Do you want me to build a new AWStats config/profile
  file (required if first install) ? y
  ...
  Your web site, virtual server or profile name:
  > www.tarena.com            //输入你的web服务器名字
  ...
  Default: /etc/awstats
  Directory path to store config file(s) (Enter for default):
  >
  ...
  /usr/local/awstats/tools/awstats_updateall.pl now
  Press ENTER to continue...
  ...
  Press ENTER to finish...
  3、指定统计的目标日志文件
  # vim /etc/awstats/awstats.www.tarena.com.conf
  ...
  51 LogFile="/var/log/httpd/access_log"
  # mkdir /var/lib/awstats
  4、将日志文件导入Awstats
  # ./awstats_updateall.pl now
  # crontab -e
  */5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now
  # service crond restart
  # chkconfig crond on
  5、验证
  验证:
  http://www.tarena.com/awstats/awstats.pl?config=www.tarena.com
  

  图(13)
  验证:
  http://www.tarena.com/awstats.html
  

  图(14)
  建立跳转页
  # vim /var/www/html/awstats.html
  
  
  
  
  
  
  

  




页: [1]
查看完整版本: http配置安装和部署Awstats统计Http访问日志