我试图在我公司的服务器上下载并安装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方法?我尝试在env变量中添加HTTP_PROXY为"http://user:password@proxy.company.loc:8080",但这没有帮助(也许我还必须在某处添加验证类型NTLM)。
服务器为Windows server 2012 R2。PHP版本为5.6.5,Apache版本为2.4.12。
感谢您的帮助,对任何语法错误表示抱歉!
我将描述我自己使用的解决方案。
- 下载cntlm-0.92.3-setup.exe并安装(它将设置系统服务)。
- 配置Cntlm .ini (C:'Program Files (x86)'Cntlm' Cntlm .ini) -代理地址,无代理,域帐户等
- 重启Cntlm认证代理服务
- 设置http_proxy/https_proxy为http://localhost:3128(系统范围方法)
- 现在尝试symfony安装程序
有时它可能有点慢,但它工作。我将此解决方案用于所有不支持与系统范围代理集成的控制台应用程序。Cntlm也可以在unix上运行。
希望对你有帮助。