Linux上的PHP curl:与windows上的curl有什么区别


PHP curl on Linux: what is the difference to curl on windows?

我正试图从Ubuntu服务器11.10运行我的php应用程序。此应用程序在windows中的Apache+PHP下运行良好。我有其他应用程序,我可以简单地复制&在2个操作系统之间粘贴,它们在两者上都可以工作。

然而,这一个使用php库tonic(RESTful Web服务),并使我们成为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日志显示:

[error]/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>

问题是Ubuntu上的默认Apache配置:

Options Indexes FollowSymLinks MultiViews

MultiViews正在将request_uri从myResource更改为myResource.php。

解决方案:

  • 禁用.htaccess:选项-多视图
  • 从默认配置中删除多视图
  • 将示例中的文件重命名为myResourceClass

我选择了最后一个选项,因为无论配置如何,这都应该有效,而且我只有3个这样的文件,所以更改大约需要30秒。。。