现在的位置: 首页 > 综合 > 正文

apache+htpasswd

2018年05月16日 ⁄ 综合 ⁄ 共 941字 ⁄ 字号 评论关闭
基于虚拟主机的密码访问:
1、在配置文件中添加:
NameVirtualHost 192.168.0.3:8080
NameVirtualHost 192.168.0.3:8081
Listen 8081
Listen 8080
<VirtualHost 192.168.0.3:8080>
DocumentRoot  /usr/local/apache/htdocs/web1
ServerName 192.168.0.3:8080
<Location />
Order deny,allow
Allow from all
Deny from all
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user rong
</Location>
</VirtualHost>
<VirtualHost 192.168.0.3:8081>
DocumentRoot  /usr/local/apache/htdocs/web2
ServerName 192.168.0.3:8081
<Location />
Order deny,allow
Allow from all
Deny from all
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user rong2
</Location>
</VirtualHost>
2、执行命令:添加2个用户:
#htpasswd  /usr/local/apache/passwd/passwords rong
New password: 
Re-type new password: 
Adding password for user rong
#htpasswd  /usr/local/apache/passwd/passwords rong2
New password: 
Re-type new password: 
Adding password for user rong2

本文出自 “Mr_Z” 博客,请务必保留此出处http://zhangrong.blog.51cto.com/2196532/986501

抱歉!评论已关闭.