//在zhoutao.name网站的跟目录下建立一个文件.htaccess,并且编辑

 


  
  1. Authname "zhoutao.name" 
  2. AuthType Basic 
  3. AuthUserFile /etc/httpd/vconf.d/zhoutao.name.htpasswd 
  4. Require valid-user 

//建立zhoutao.name 域的密码文件,并且文件必须被apache组可读

 


  
  1. [root@centos129 zhoutao.name]# htpasswd -cm /etc/httpd/vconf.d/zhoutao.name.htpasswd zhoutao 
  2. New password:  
  3. Re-type new password:  
  4. Adding password for user zhoutao 
  5. chgrp apache /etc/httpd/vconf.d/zhoutao.name.htpasswd
  6. chmod g+r /etc/httpd/vconf.d/zhoutao.name.htpasswd

//添加虚拟主机配置文件中<Directiry>增加

AllowOverride AuthConfig

//测试

访问www.zhoutao.name 提示输入密码,

成功进入