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服務器配置用戶認證


分享到:


相關文章: