$_SERVER['PHP_AUTH_DIGEST'] 为空并且启用了 mod_auth_digest

$_SERVER['PHP_AUTH_DIGEST'] 为空并且启用了 mod_auth_digest

sudo apachectl -t -D DUMP_MODULES 的输出

Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 headers_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 ssl_module (shared)
 status_module (shared)
Syntax OK

似乎表明摘要身份验证模块正在我的服务器上运行,但是当我尝试访问 $_SERVER['PHP_AUTH_DIGEST'] 时,该变量不存在。

我的虚拟主机设置是:

<VirtualHost *:80>
        ServerName sam
        DocumentRoot /var/www/sam/public/
        ErrorLog /var/log/apache2/sam-error.log

        SetEnv APPLICATION_ENV "development"

        <Directory /var/www/sam/public>
                DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
                #AuthType Digest
                #AuthName "api"
        </Directory>
</VirtualHost>

答案1

在您的 Apache 配置中,您尚未启用摘要式身份验证. 尝试取消注释相关行并通过以下方式重新启动 Apache sudo /etc/init.d/apache2 restart

<VirtualHost *:80>
        ServerName sam
        DocumentRoot /var/www/sam/public/
        ErrorLog /var/log/apache2/sam-error.log

        SetEnv APPLICATION_ENV "development"

        <Directory /var/www/sam/public>
                DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
                AuthType Digest
                AuthName "api"
        </Directory>
</VirtualHost>

如果此操作不起作用或者出现服务器错误,请检查错误日志/var/log/apache2/access.log

如果你实施摘要式身份验证,你可能需要检查php.net 上的摘要式身份验证示例$_SERVER.可以找到所有变量的描述这里

相关内容