※[]里面的内容自己设置
1.生成密码文件
如果是生成新的密码文件
# cd /usr/apache2/bin
# htpasswd -bc [filename] [userName] [password]
如果使用已有的密码文件
# cd /usr/apache2/bin
# htpasswd -b [filename] [userName] [password]
2.修改/etc/apache2/httpd.conf
<Directory "[File Path]">
AuthType Basic
AuthName " [userName]"
AuthUserFile /usr/apache2/bin/[filename]
Require user [userName]
</Directory>
3.重启apache
# svcadm restart apache2
1.生成密码文件
如果是生成新的密码文件
# cd /usr/apache2/bin
# htpasswd -bc [filename] [userName] [password]
如果使用已有的密码文件
# cd /usr/apache2/bin
# htpasswd -b [filename] [userName] [password]
2.修改/etc/apache2/httpd.conf
<Directory "[File Path]">
AuthType Basic
AuthName " [userName]"
AuthUserFile /usr/apache2/bin/[filename]
Require user [userName]
</Directory>
3.重启apache
# svcadm restart apache2