apache其安装目录下bin子目录下有htpasswd工具建立密码文件,非常方便,如:
htpasswd -c /usr/local/apache/passwd/passwords username
将会提示你输入密码和确认密码,如:
New password: mypassword
Re-type new password: mypassword
Adding password for user username
再在http.conf里增加类似如下内容:
AllowOverride AuthConfig
AuthType Basic
AuthName "限制文件"
AuthUserFile /usr/local/apache/passwd/passwords
Require user username
这样就能实现需求了.