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

Linux上的PHP curl:与windows上的curl有什么区别?,php,libcurl,ntlm,Php,Libcurl,Ntlm,我正在尝试从Ubuntu服务器11.10运行我的php应用程序。此应用程序在windows中的Apache+PHP下运行良好。我有其他的应用程序,我可以简单地在两个操作系统之间复制和粘贴,它们可以同时在两个操作系统上工作 然而,这一个使用php库tonic(RESTfulWebServices)并使我们了解php cURL模块。问题是我没有收到错误消息,这使得我无法找到问题 我(必须)使用NTLM身份验证,这是通过AuthenNTLM Apache模块完成的: Order allow,deny

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

然而,这一个使用php库tonic(RESTfulWebServices)并使我们了解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进行fectehd,因此访问权限可以限制为localhost

可能的问题包括:

  • 对于通过cURL请求的文件,不会覆盖NTLM auth(即使设置了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>

406不可接受
不可接受
在此服务器上找不到请求的资源/myApp/webservice/myResource的适当表示形式

可用的变体:
  • ,键入application/x-httpd-php

本地主机端口80上的Apache/2.2.20(Ubuntu)服务器
问题是Ubuntu上的默认Apache配置:

Options Indexes FollowSymLinks MultiViews
MultiView正在将请求uri从myResource更改为myResource.php

解决方案:

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

我选择了最后一个选项,因为无论配置如何,它都可以工作,我只有3个这样的文件,所以更改大约需要30秒…

我认为这篇文章更适合