编辑配置文件 vim /etc/httpd/conf/httpd.conf 添加
<Directory "www/html/zhou">
Options none
AllowOverRide none
AuthType Basic
AuthName "STRING"
AuthUserFile "/etc/httpd/conf.d/.htpasswd"
Require valid-name
</Directory>
保存退出
htpasswd -c -m /etc/httpd/conf.d/.htpasswd user 再键入密码 -c 尽在第一次使用时用于创建/etc/httpd/conf.d/.htpasswd -m:用md5加密
service httpd reload 重新载入配置文件