版权声明:学研之路长而漫,长情与君总会见! https://blog.csdn.net/Aaron_Miller/article/details/80582625
一、实验环境
VMware CentOS 6.5 IP:192.168.43.226
二、操作步骤
1.创建主页目录,主页文件
mkdir /www
vi /www/index.html
2.修改配置文件/etc/httpd/conf/httpd.conf
# 在虚拟主机后追加(1009行后):
<VirtualHost *:80>
DocumentRoot /www #指定访问主页目录
<Directory /www>
Order allow,deny #指定ACL策略顺序
Allow from 192.168.43.226
AuthType Basic #认证类型
AuthName "~" #提示语
AuthUserFile /etc/httpd/webpasswd #指定认证文件保存路径
require user Kevin Kevin2 #指定可登陆用户,此为Kevin
<Directory>
</VirtualHost>
【ACL:/Access Control List/访问控制列表:控制网络流量允许特定设备访
问,可提高网络性能,如禁止局域网访问外部网络或只能用ftp服务 】
3.创建认证文件并添加用户
》》htpasswd -c /etc/httpd/webpasswd Kevin
》》htpasswd -c /etc/httpd/webpasswd Kevin2
4.重启Apache服务
》》service httpd restart