实验一:查看默认HTTP配置

找到默认红帽欢迎页面

(/etc/httpd/conf/httpd.conf ---->Include ---->/etc/httpd/conf.d  ---->welcome.conf  ---->/var/www/error/noindex.html)

[root@wolaile sbin]# rpm -q httpd

[root@wolaile sbin]# yum -y install httpd

[root@wolaile sbin]# service httpd restart

[root@wolaile sbin]# chkconfig httpd on

[root@wolaile sbin]# vim /etc/hosts

192.168.10.100 web01.tarena.com web01

试验二:基本HTTP服务器的配置

   Web服务器域名:www.tarena.com

   默认首页包括:index.html、index.php

   开启保持连接

   确认默认httpd是否支持php    

   网站用老师提供的test_web.zip测试

[root@wolaile sbin]# cd /etc/httpd/conf

[root@wolaile conf]# cp httpd.confhttpd.conf.bak

[root@wolaile conf]# vim/etc/httpd/conf/httpd.conf

74 KeepAlive On             是否保持连接

265 ServerName www.tarena.com:80  本站点的FQDN名称

400 DirectoryIndex index.html index.php首页文件

[root@wolaile conf]# service httpd restart

[root@wolaile conf]# chkconfig httpd on

[root@wolaile conf]# cd /root/Desktop/

[root@wolaile Desktop]# unzip test_web.zip

[root@wolaile Desktop]# mv jiajutiyan/* /var/www/html/

[root@wolaile Desktop]# vim  /var/www/html/test.php编写测试PHP页面

< ?php

   phpinfo(gogogog);

?>

测试:

www.tarena.com

www.tarena.com/test.php

windows 下设置hosts文件

C:\windows\System32\drivers\etc

 

实验三:httpd访问控制权限

 [root@wolaile Desktop]# vim/etc/httpd/conf/httpd.conf

允许所有客户机访问

<Directory /var/www/html>

Order allow,deny 先允许后拒绝,默认拒绝所有

Allow from all 允许所有

</Directory>

 

只允许192.168.10.200访问www.tarena.com

<Directory /var/www/html>

Order allow,deny 先允许后拒绝,默认拒绝所有

Allow from 192.168.10.200设置权限只允许192.168.10.200

</Directory>

 

允许所有用户访问www.tarena.com/authdir/index.html

[root@wolaile ~]# mkdir/var/www/html/authdir

[root@wolaile~]#

 echo “http://www.tarena.com/authdir/index.html">/var/www/html/authdir/index.html

[root@wolaile ~]# vim/etc/httpd/conf/httpd.conf

<Directory /var/www/html/authdir>

Order allow,deny 先允许后拒绝,默认拒绝所有

Allow from all 允许所有

</Directory>

在不同客户端测试

 

[root@wolaile ~]# tail/var/log/httpd/error_log查看HTTP日志文件

试验四:HTTP的用户授权

   客户端访问http://www.tarena.com/authdir需要输入用户名密码验证

[root@wolaileDesktop]# vim /etc/httpd/conf/httpd.conf

<Directory/var/www/html/authdir>

       Order allow,deny先允许后拒绝,默认拒绝所有Orderdeny,allow先拒绝,然后允许所有

        Allow from all允许所有Allow dengy all拒绝所有

        AuthName "Please InputPassword"认证领域名称,用于弹窗提示

        AuthType Basic认证类型,一般使用basic

        AuthUserFile"/etc/httpd/.passwd"用户数据文件的路径

        Require valid-user指定授权用户或组或者Requireuser(组用group)用户1 用户2

</Directory>

[root@wolaile~]# htpasswd -c /etc/httpd/.passwd admin

Newpassword:

Re-typenew password:

[root@wolaile~]# service httpd restart

测试:客户端访问http://www.tarena.com/authdir

实验五:HTTP目录别名

   客户端访问http://www.tarena.com/sina时可以访问/var/www/html/sina.com/bbs下的网页

[root@wolaile~]# mkdir -p /var/www/html/sina.com/bbs

[root@wolaile~]# vim /var/www/html/sina.com/bbs/index.html

<html><head><title> this is atestpage!!!</title></head><body><h1>thisbbs.sina.comtestpage!!!</h1></body></html>

[root@wolaile~]# vim/etc/httpd/conf/httpd.conf

Alias/sina "/var/www/html/sina.com/bbs"

[root@wolaile~]# service httpd restart

测试:客户端访问http://www.tarena.com/sina

实验六:

   查看默认HTTP使用进程管理方式

   更改默认进程管理方式为worker模式

[root@wolaile~]# httpd -l

Compiledin modules:

  core.c

  prefork.c

  http_core.c

  mod_so.c

[root@wolailesbin]# ls http*

httpd  httpd.event httpd.worker

[root@wolailesbin]# mv httpd httpd.prefork

[root@wolailesbin]# mv httpd.worker httpd

[root@wolailesbin]# httpd -l

Compiledin modules:

  core.c

  worker.c

  http_core.c

  mod_so.c

试验七:

   部署Awstats统计Http访问日志

[root@wolailesbin]# cd /usr/src/

[root@wolailesrc]# cd /root/Desktop/

[root@wolaileDesktop]# tar -zxvf awstats-7.1.tar.gz -C /usr/local/

[root@wolailetools]# cd /usr/local/

[root@wolailelocal]# mv awstats-7.1/ awstats

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

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

[root@wolailetools]# ./awstats_configure.pl

Do youwant to continue setup from this NON standard directory [yN] ? y

file(required if first install) [y/N] ? y

>/etc/httpd/conf/httpd.conf指定WEB配置路径

>回车,接受配置路径/etc/awstats

>www.tarena.com指定网站名称

[root@wolailetools]# vim /etc/awstats/awstats.www.tarena.com.conf站点配置文件

LogFile="/var/log/httpd/access_log"要分析的日志文件

DirData=”/var/lib/awstats”默认工作目录

[root@wolailetools]# ./awstats_updateall.pl new手动更新所有站点

[root@wolailetools]# crontab -e

*/5 * ** * /usr/local/awstats/tools/awstats_updateall.pl now5分钟更新一次

[root@wolailetools]# service crond restart

验证:http://www.tarena.com/awstats/awstats.pl?config=www.tarena.com