apache虚拟目录的创建及身份验证功能的开启

apache虚拟目录的创建及身份验证功能的开启

实验环境:服务端:centos6.5 IP192.168.10.10
客户端:win7
1.echo "test01" > /var/www/html/index.html //将首页改为test01
vim /etc/httpd/conf/httpd.conf
apache虚拟目录的创建及身份验证功能的开启
//添加可识别网页文件类型
vim vuser.conf //自定义创建虚拟目录
Alias /test "/opt/test"
<Directory "/opt/test/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
AuthName "hello"
authtype basic
authuserfile /etc/httpd/user
require Valid-user
</Directory>
apache虚拟目录的创建及身份验证功能的开启
echo "this is vdir test" > /opt/test/index.html //在opt/test/ 创建网页"this is vdir test"
客户端访问服务端IP:http://192.168.10.10/test/
apache虚拟目录的创建及身份验证功能的开启
虚拟目录创建成功
2.开启身份验证功能
htpasswd -c /etc/httpd/user baixiaosheng //创建虚拟用户baixiaosheng,并设置密码
vim vuser.conf
apache虚拟目录的创建及身份验证功能的开启
service httpd restart //重启服务
客户端再次访问服务端
apache虚拟目录的创建及身份验证功能的开启
需验证身份才能访问站点

猜你喜欢

转载自blog.51cto.com/13842738/2164844