[英]Install Symfony on Windows behind proxy server with NTLM authentication
我试图在我公司的服务器上下载并安装Symfony ...
c:\> php -r "readfile('http://symfony.com/installer');" > symfony
..并收到以下错误(部分是德语,但您会明白的):
PHP Warning: readfile(http://symfony.com/installer): failed to open stream: Es konnte keine Verbindung hergestellt werd en, da der Zielcomputer die Verbindung verweigerte.
in Command line code on line 1
因此,我通过浏览器手动下载了它(效果很好),并尝试创建一个新站点:
php symfony.phar new blog
现在我得到了这个错误:
[RuntimeException]
There was an error downloading Symfony from symfony.com server:
Client error response [url] http://symfony.com/download?v=Symfony_Standard_Vendors_latest.tgz [status code] 407 [re
ason phrase] Proxy Authentication Required
[GuzzleHttp\Exception\ClientException]
Client error response [url] http://symfony.com/download?v=Symfony_Standard_Vendors_latest.tgz [status code] 407 [re
ason phrase] Proxy Authentication Required
所以我退后一步,看看是否可以在PHP脚本中执行cURL请求。 我使用以下脚本进行尝试(我的公司正在使用具有NTLM身份验证的代理服务器):
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, 'proxy.company.loc');
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
echo curl_exec($ch);
curl_close($ch);
而且效果很好。
我必须做些什么才能能够安装和使用Symfony。 我在哪里定义代理,凭据和NTLM方法? 我尝试在环境变量中将HTTP_PROXY添加为“ http:// user:password@proxy.company.loc:8080 ”,但这没有帮助(也许我还必须在某处添加身份验证类型NTLM)。
该服务器是Windows Server 2012 R2。 PHP版本是5.6.5,Apache是2.4.12。
感谢您的帮助,对于任何语法错误,我们深表歉意!
我将描述自己使用的解决方案。
有时可能会有点慢,但可以。 我将这种解决方案用于所有不支持与系统范围代理集成的控制台应用程序。 Cntlm也可以在基于unix的OS上工作。
希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.