Apache实现用户验证访问
1、修改Apache主配置文件# vim /usr/local/apache2/conf/httpd.conf
AllowOverride AuthConfig//改成AuthConfig
2、在虚拟主机的主目录下创建.htaccess文件
# cd /usr/local/apache2/htdocs/
# vim .htaccess
AuthName "frank share web" //受保护的领域名称
AuthType Basic //认证类型
AuthUserFile /usr/local/apache2/htdocs/.htpasswd //用户认证文件
require valid-user 3、创建认证用户和密码
# /usr/local/apache2/bin/htpasswd -c /usr/local/apache2/htdocs/.htpasswd test //第一次创建需要-c参数
New password:
Re-type new password:
Adding password for user test//修改认证用户密码
# /usr/local/apache2/bin/htpasswd -m /usr/local/apache2/htdocs/.htpasswd test
New password:
Re-type new password:
Updating password for user test 4、验证
# curl 192.168.0.104 -I
HTTP/1.1 500 Internal Server Error
Date: Sat, 19 Apr 2014 07:51:41 GMT
Server: Apache/2.2.16 (Unix) PHP/5.3.27
Connection: close
Content-Type: text/html; charset=iso-8859-1
页:
[1]