【发布时间】:2012-03-22 12:09:04
【问题描述】:
我正在尝试从 Ubuntu Server 11.10 运行我的 php 应用程序。这个应用程序在 Windows 中的 Apache + PHP 下运行良好。我还有其他应用程序,我可以简单地在 2 个操作系统之间复制和粘贴,它们都可以在这两个操作系统上运行。
然而,这个使用 php 库 tonic (RESTful webservices) 并使我们使用 php cURL 模块。问题是我没有收到导致无法找到问题的错误消息。
我(必须)使用 NTLM 身份验证,这是通过 AuthenNTLM Apache 模块完成的:
Order allow,deny
Allow from all
PerlAuthenHandler Apache2::AuthenNTLM
AuthType ntlm
AuthName "Protected Access"
require valid-user
PerlAddVar ntdomain "domainName server"
PerlSetVar defaultdomain domainName
PerlSetVar ntlmsemtimeout 2
PerlSetVar ntlmdebug 1
PerlSetVar splitdomainprefix 0
cURL 需要获取的所有文件都会覆盖 AuthenNTLM 身份验证:
order deny,allow
deny from all
allow from 127.0.0.1
Satisfy any
由于这些文件仅受来自同一服务器的 cURL 感染,因此可以将访问限制为 localhost。
可能的问题是:
对于通过 cURL 请求的文件,不会覆盖 NTLM 身份验证(即使设置了 AllowOverride All)
-
curl 在 linux 上的工作方式不同
$ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIE, $strCookie); curl_setopt($ch, CURLOPT_URL, $baseUrl . $queryString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec($ch); curl_close($ch); 其他?
Apache 日志说:
[错误] /myApp/webservice/local/viewList.php 的错误/缺少 NTLM/基本授权标头
但是这个目录应该覆盖 NTLM 身份验证
编辑:
使用来自 windows 的 curl 命令行来访问我得到的相同资源:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>406 Not Acceptable</title>
</head>
<body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /myApp/webservice/myResource could not be found on this server.</p>
Available variants:
<ul>
<li><a href="myResource.php">myResource.php</a> , type application/x-httpd-php</li>
</ul>
<hr>
<address>Apache/2.2.20 (Ubuntu) Server at localhost Port 80</address>
</body>
</html>
【问题讨论】:
-
我觉得这个帖子更适合Server Fault