站长资讯网
最全最丰富的资讯网站

Centos7 Apache服务器配置用户认证

1.生成认证文件/etc/httpd/password

[root@bogon /]# htpasswd -c /etc/httpd/password zhangsan
New password:
Re-type new password:
Adding password for user zhangsan
[root@bogon /]# htpasswd /etc/httpd/password lishi
New password:
Re-type new password:
Adding password for user lishi
[root@bogon /]#
[root@bogon /]# cat /etc/httpd/password
zhangsan:$apr1$GepjhXih$XOhB.VdkohgSQtmGUAMYb1
lishi:$apr1$5dPs76l2$OcITuDWwHlXV6lRQLC/2e0
[root@bogon /]#

2.在/etc/httpd/conf/httpd.conf 加如下内容:

Alias /app22 /app2

AuthType Basic
Authname "This is a private dir"
AuthUserFile /etc/httpd/password #用htpasswd 命令生成的认证文件
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require valid-user #请求/app2时要求用户认证

3.关闭selinux防火墙:setenforce 0

4.service httpd restart

5.测试访问

Centos7 Apache服务器配置用户认证

赞(0)
分享到: 更多 (0)
网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号