2019-02-07 CentOS WEB账号密码登陆配置

LogAnalyzer装好以后,我想增加账号密码登陆配置,CentOS 7的httpd配置文件在/etc/httpd/conf/httpd.conf 文件,LogAnalyzer工作目录在 /var/www/html/log/目录。
1、修改httpd.conf文件,增加:


    AllowOverride AuthConfig

2、在LogAnalyzer目录增加认证文件:

[root@syslog-http log]#cd /var/www/html/log && vim .htaccess

#Options -indexes

AuthName "Please Login"  
AuthType Basic
#指定密码文件存放位置
AuthUserFile /var/www/html/log/htpasswd.users  
#哪些用户有权限,其他用户依次增加
require user axing user1 user2 

3、创建用户密码:

[root@syslog-http log]# htpasswd -c /var/www/html/log/htpasswd.users axing
[root@syslog-http log]# htpasswd  /var/www/html/log/htpasswd.users user1

注意,第一个用户加参数 -c,后面就不要加了,否则会覆盖掉前面的
4、重启httpd服务,再去访问页面就要求用户名密码了。

[root@syslog-http log]# systemctl restart httpd.service

5、认证用户管理

htpasswd -m /var/www/html/log/htpasswd.users  user1   修改用户名密码
htpasswd -D /var/www/html/log/htpasswd.users  user2   删除用户

其他目录的访问控制也类似,自己定义目录和密码文件即可。

你可能感兴趣的:(2019-02-07 CentOS WEB账号密码登陆配置)