Apache 增加登录认证


1.启用Apache的auth_basicauthn_file模块,默认启用

2.生成密码

/usr/local/apache2/bin/htpasswd -c /home/apachepasswd 用户名

3.加入认证

<directory /home/xxx/>
AddDefaultCharset UTF-8
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
AuthName "用户名"
AuthType Basic
AuthUserFile /home/apachepasswd
Require valid-user
</directory>