apache 简单认证访问
web 站点的某些页面需要制定的用户口令才能看到的话需要在apache 的相关配置做一下修改。1、若是开启虚拟主机,则将/etc/apache2/site-enabled/000-default中的块全部注释掉(里面有访问规则,影响配置结果)。没开启虚拟主机的则将/etc/apache2/apache.conf中的Include /etc/apache2/site-enabled/ 注释掉。
2.vim /etc/apache2/httpd.conf
Alias /sarg "/var/www/sarg" #目录别名映射,在地址栏输入1.1.1.135/sarg 即可连接到根目录
Options Indexes MultiViews
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all
3. 创建并编辑 vim /etc/apache2/sarg/.htaccess
AuthName "view log analyse passwd needed" #用户密码验证框出现时候的信息标题 可以自定义
AuthType Basic
AuthUserFile /var/www/sarg/.htpasswd
require user yunwei #也可以require valid-user
4.就是创建apache的验证用户
#htpasswd -cm /var/www/sarg/.htpasswd yunwei
5./etc/init.d/apache2 reload 进行验证
页:
[1]