apache+htpasswd

来源:互联网 发布:ubuntu切换打字法 编辑:程序博客网 时间:2024/04/28 16:45
基于虚拟主机的密码访问:

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

原创粉丝点击