1:首先创建两个用户并且设置密码:
htpasswd -c /etc/httpd/zhanghao abc
htpasswed /etc/httpd/zhanghao tom
2:查看是否创建成功
cat /etc/httpd/zhang
3:创建目录并输入信息进去
mkdir /usr/local/mysecret
echo "hehe" > /usr/local/mysecrrt
4:配置目录/etc/httpd/cong.d/vhost.conf中的配置信息
<directory /usr/local/mysecret>
authtype basic
authname "please enter your passwd: "
authuserfile /etc/httpd/zhanghao
require user abc tom
</directory>
<virtualhost 192.168.64.134:80>
documentroot /www/hehe
alias /hehe /usr/local/mysecret/index.html
servername www.hehe.com
</virtualhost>
5:创建网站目录并输入信息
cd /www
mkdir /www/hehe
echo hehe>/www/hehe.index.html
6:在/etc/hosts中添加域名
7:本地winodw中添加域名(需要用管理员权限进行修改保存)
8:重启服务
systemctl restart httpd
9:测试