apache用户认证

一 修改http.conf文件

<Directory "/var/www/t/">
Options Indexes
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all
</Directory>

 

其中第4行AllowOverride项要设置成AuthConfig,表示允许.htaccess文档中的认证指令,当然,可以设置为all,将执行.htaccess中所有的配置;none则忽略.htaccess文档。第一步可以跳过。

 

二 修改.htaccess文件

AuthType Basic
AuthName "welcome to here"
AuthUserFile /var/www/html/t/.htpassword
Require valid-user

 

三 生成用户密码文件

htpasswd -c /var/www/t/.htpassword admin

不要自己编辑.htpassword文件,因为apache有自己的加密机制。(这个问题困扰了我半天,每次认证都显示500)

 

posted @ 2014-08-04 14:33  帽子戏法  阅读(195)  评论(0编辑  收藏  举报
全部 html css js Linux php MySQL seo web git other 联系 管理