Apache的应用四-- 基本身份认证
2010-06-08 23:26
369 查看
Apache服务器提供基本的身份认证技术 ,限定用户访问浏览页面的保密程度
场景:现一有Apache服务器,IP为192.168.152.100。网站主目录在/var/webroot,在网站根目录下有目录auth(即/var/webroot/auth),需要输入用户名和密码才能访问.
产生效果如图:
步骤:
1、检查服务器的IP,是否正确
使用命令
Ifconfig eth0 查看,确认你的IP地址
(若有多块网卡,就直接使用ifconfig命令查看)
2、查看服务器的主目录,并在主目录下建立目录auth 及建立访问测试页面auth.html
# mkdir /var/webroot/auth
# cd /var/webroot/auth
# touch auth.html
# echo "This auth file page, Welcome" > auth.html
3、创建访问用户
假设要使用 user1用户进行访问,密码为123
htpasswd -c /etc/httpd/htpasswd user1
New password:
Re-type new password:
Adding password for user user1
4、编辑配置文件 /etc/httpd/conf/httpd.conf
]# vim /etc/httpd/conf/httpd.conf
修改的内容为:
Listen 80
DocumentRoot "/var/webroot"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/webroot">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
<Directory "/var/webroot/auth">
DirectoryIndex auth.html
Options Indexes
AllowOverride Authconfig
AuthType Basic
AuthBasicProvider file
AuthUserFile /etc/httpd/htpasswd
AuthName "Please Enter Your Username and Password!!!"
Require user user1
</Directory>
5、重启动httpd服务,使用浏览器访问
可以看到结果
完成实验
这是使用用户名和密码的最基本的方式,缺点是,用户和密码是明文传送,所以不安全。
场景:现一有Apache服务器,IP为192.168.152.100。网站主目录在/var/webroot,在网站根目录下有目录auth(即/var/webroot/auth),需要输入用户名和密码才能访问.
产生效果如图:
步骤:
1、检查服务器的IP,是否正确
使用命令
Ifconfig eth0 查看,确认你的IP地址
(若有多块网卡,就直接使用ifconfig命令查看)
2、查看服务器的主目录,并在主目录下建立目录auth 及建立访问测试页面auth.html
# mkdir /var/webroot/auth
# cd /var/webroot/auth
# touch auth.html
# echo "This auth file page, Welcome" > auth.html
3、创建访问用户
假设要使用 user1用户进行访问,密码为123
htpasswd -c /etc/httpd/htpasswd user1
New password:
Re-type new password:
Adding password for user user1
4、编辑配置文件 /etc/httpd/conf/httpd.conf
]# vim /etc/httpd/conf/httpd.conf
修改的内容为:
Listen 80
DocumentRoot "/var/webroot"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/webroot">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
<Directory "/var/webroot/auth">
DirectoryIndex auth.html
Options Indexes
AllowOverride Authconfig
AuthType Basic
AuthBasicProvider file
AuthUserFile /etc/httpd/htpasswd
AuthName "Please Enter Your Username and Password!!!"
Require user user1
</Directory>
5、重启动httpd服务,使用浏览器访问
可以看到结果
完成实验
这是使用用户名和密码的最基本的方式,缺点是,用户和密码是明文传送,所以不安全。
相关文章推荐
- 如何用Apache与MySQL整合实现基本身份认证_PHP教程
- apache 基本认证的使用
- ASP.Net 身份验证方法 基本的Forms认证步骤 [转]
- Kerberos身份认证在域用户工作站登录中的应用
- Linux+Apache用 mod_auth_mysql实现用户身份认证
- 在Weblogic环境下的servlet中实现应用级身份认证
- Apache Shiro身份认证(Authentication)
- AngularJS 应用身份认证的技巧
- Apache cxf JaxWs基本应用
- 【Shiro】Apache Shiro架构之身份认证(Authentication)
- 使用Apache Shiro进行身份认证-Active Directory认证
- 采用普通的脱机指纹终端来实现大容量指纹身份认证应用(超过3000枚)是不可取的
- 【Shiro】Apache Shiro架构之身份认证(Authentication)
- 企业级应用身份认证管理扫盲篇——协议
- Apache shiro集群实现 (三)shiro身份认证(Shiro Authentication)
- Apache shiro集群实现 (三)shiro身份认证(Shiro Authentication)
- Apache Flink应用开发之API基本概念(更新中。。。)
- php创建基本身份认证站点
- Linux配置svn+apache+ssl+radius身份认证
- AngularJS 应用身份认证的技巧