1. 创建password.
一般把password放在Apache Server上。
在Apache目录下创建user文件夹.
用htpasswd创建password.
>cd "c:\Program Files\Apache Group\Apache2\bin"
>htpasswd -bc ..\user\password.txt user test
此命令在user文件夹中创建一个本文文件password.txt,并且创建了一个用户名user和密码test
如果想要继续添加用户名和密码:>htpasswd -b ..\user\password.txt user1 test
2. 修改Apache配置文件.
打开conf/httpd.conf,在文件最后添加:
<Directory "要验证的文件目录">
Options Indexes FollowSymLinks Allowoverride authconfig Order allow,deny Allow from all AuthName "Ironman Data API" AuthType Basic AuthUserFile "C:/Program Files/Apache Group/Apache2/user/password.txt" require valid-user </Directory> 3. 重新启动Apache Server.
|
|