I'm trying to run my php App on Ubuntu Server 11.10. This App works fine under Apache + PHP in windows. I have other applications that I can simply copy&paste between the 2 OS and they work on both. (These don't use cURL).
However this one uses the php library tonic (RESTful webservices) and makes us of php cURL module. The issue is I'm not getting an error message which makes it impossible to find the issue.
I (must) use NTLM authentication and this is done with AuthenNTLM Apache Module:
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
All files that cURL needs to fetch override AuthenNTLM authentication:
order deny,allow
deny from all
allow from 127.0.0.1
Satisfy any
Since these files are only fectehd by cURL from same server, access can be limited to localhost.
Possible issues are:
NTLM auth isn't overridden for files requested through cURL (even though AllowOverride All is set)
curl works differently on 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);
other?
Apache log says:
[error] Bad/Missing NTLM/Basic Authorization Header for /myApp/webservice/local/viewList.php
But this directory should override NTLM authentication
using curl command line from windows to access same resource i get:
<!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>
Note:
This is duplicate from http://stackoverflow.com/questions/9821979/php-curl-on-linux-what-is-the-difference-to-curl-on-windows
Is it was suggested I post it here.
EDIT:
Please see
Ubuntu Server: Apache2 seems to attach .php to URI
as I discovered why it does not work but need help so the issue does not occur anymore.
ANSWER:
The issue is the default Apache configuration on Ubuntu:
Options Indexes FollowSymLinks MultiViews
MultiViews is changing request_uri from myResource to myResource.php.
Solutions:
disable MultiViews in .htaccess: Options -MultiViews
remove MultiViews from default config
rename the file as example to myResourceClass
I chose last option because that should work regardless of configuration and I only have 3 such files so the change took about 30 secs...