![Linux:Centos:启用基本身份验证](https://linux22.com/image/600705/Linux%EF%BC%9ACentos%EF%BC%9A%E5%90%AF%E7%94%A8%E5%9F%BA%E6%9C%AC%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81.png)
我正在尝试为 Linux(centos)服务器设置基本身份验证。
我做了以下事情:
mkdir /usr/local/apache
mkdir /usr/local/apache/passwd
echo > /usr/local/apache/passwd/passwords
htpasswd -c /usr/local/apache/passwd/passwords some_user
new password: xxxxxx
confirm password: xxxxxx
这是虚拟主机部分:
NameVirtualHost *:80
ServerName localhost
ServerAlias some.example.site.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite/web/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Alias /winapi /var/www/another_section/
<Directory "/var/www/another_section">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
....
基本身份验证指令去哪里了?(为整个虚拟主机提供基本身份验证保护):
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /usr/local/apache/passwd/passwords
Require user some_user
答案1
基本身份验证进入您的<Directory>
区块。