apache安装于/usr/local/apache,主页在/usr/local/apache/htdocs
#vi /usr/local/apache/htdocs/.htAccess
AuthName Protected
AuthUserFile /usr/local/apache/.htpasswd
AuthType Basic
require valid-user
#vi /usr/local/apache/.htpasswd
robert:A101E2ThTjG4.
#/usr/local/apache/bin/htpasswd [-c] /usr/local/apache/.htpasswd robert
没有该.htpasswd文件时使用一次-c,以后无需使用。 (陈绪)
(出处:http://www.sheup.com)