Linux:Centos:启用基本身份验证

Linux:Centos:启用基本身份验证

我正在尝试为 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>区块。

相关内容