1. 修改httpd.conf, 对要做认证的目录进行设置
<Directory "/usr/local/var/www">
   Options Indexes FollowSymLinks
   AllowOverride AuthConfig
   Order allow,deny
   Allow from all
</Directory>

 

2. 到目录/usr/local/www下增加.htaccess
AuthName "passwd, sir!"
AuthType Basic
AuthUserFile /usr/local/share/apache2/.htpasswd
require valid-user
弹出窗口提示 passwd,sir
解析密码文件为/usr/local/share/apache2/.htpasswd,用.ht打头,apache是不允许web访问到的
valid-user密码文件中匹配的用户都通过
如果是 require bruce,则只有bruce用户通过

 

3.使用apache/bin目录下的管理用户名密码,MD5保存的
/usr/local/share/apache2/.htpasswd
新建文件并增加用户 /apache/bin/htpasswd -c /usr/local/share/apache2/.htpasswd  xxxx(用户名)
会提示输入密码
增加用户 /apache/bin/htpasswd /usr/local/share/apache2/.htpasswd xxx2
修改密码 /apache/bin/htpasswd -m/usr/local/share/apache2/.htpasswd xxx
再重启apache即可生效。

 

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-02-07
  • 2022-01-07
猜你喜欢
  • 2022-02-14
  • 2022-12-23
  • 2021-07-24
  • 2022-02-19
  • 2022-12-23
  • 2021-11-18
  • 2021-11-25
相关资源
相似解决方案