apache访问密码设置步骤
一、建立密码文件
htpasswd -c /etc/httpd/conf/passwd.users admin New password: admin Re-type new password: admin
用户名admin 密码admin
二、修改配置文件
在虚拟主机中加入:
<VirtualHost *:80>
Options -Indexes FollowSymLinks
# ServerAdmin admin@test.com
DocumentRoot "/var/www/html"
# ServerName test.com
<Directory /var/www/html>
AuthName "Need Password To Access"
AuthType Basic
AuthUserFile /ect/httpd/conf/passwd.users
Require valid-user
</Directory>
ErrorLog logs/test.com
</VirtualHost>
三、启动apache
检查apache配置文件语法/usr/sbin/httpd -t
出现 Syntax OK 就是是没有语法错误了,可以启动了
service httpd start
参考文章
http://www.cnblogs.com/jiji262/archive/2012/01/16/2323636.html