在带有NTLM身份验证的代理服务器后面的Windows上安装Symfony [英] Install Symfony on Windows behind proxy server with NTLM authentication

查看:438
本文介绍了在带有NTLM身份验证的代理服务器后面的Windows上安装Symfony的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我公司的服务器上下载并安装Symfony ...

  c:\> php -rreadfile('http://symfony.com/installer'); > symfony 

..并得到以下错误(部分是德语,但你会得到的想法):

  PHP警告:readfile(http://symfony.com/installer):无法打开流:Es konnte keine Verbindung hergestellt werd en,da der Zielcomputer die Verbindung verweigerte。 
在第1行的命令行代码

所以我通过浏览器手动下载工作正常)并尝试创建一个新网站:

  php symfony.phar new blog 
  

[RuntimeException]
从symfony.com服务器下载Symfony时出错:
客户端错误响应[url] http://symfony.com/download?v=Symfony_Standard_Vendors_latest.tgz [状态代码] 407 [ re
ason phrase]需要代理验证

[GuzzleHttp \Exception\ClientException]
客户端错误响应[url] http://symfony.com/download?v= Symfony_Standard_Vendors_latest.tgz [status code] 407 [re
ason phrase]需要代理验证

我做了一步,看看我是否可以在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 vars中的HTTP_PROXY添加为 http:// user:password@proxy.company.loc :8080 ,但是没有帮助(也许我还要在某处添加auth类型NTLM)。



服务器是Windows Server 2012 R2。 PHP版本是5.6.5,Apache是​​在2.4.12。



感谢任何语法错误的帮助和遗憾。


  1. 下载 =http://cntlm.sourceforge.net/ =nofollow> cntlm-0.92.3-setup.exe 并安装它(它将设置系统服务)。

  2. 配置cntlm.ini(C:\Program文件(x86)\Cntlm\cntlm.ini) - 代理地址,无代理,域帐户等。

  3. 重新启动Cntlm身份验证代理服务。

  4. 将http_proxy / https_proxy设置为 http:// localhost:3128 <

有时它可能是一个有点慢,但它工作。我对所有不支持与系统范围代理集成的控制台应用程序使用此解决方案。 Cntlm也适用于基于unix的操作系统。



希望有帮助。


I tried to downlaod and install Symfony on a server at my company...

c:\> php -r "readfile('http://symfony.com/installer');" > symfony

..and got the following error (partly German, but you'll get the idea):

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

So I downloaded it manually over the browser (which worked fine) and tried to create a new site:

php symfony.phar new blog

Now I got this error:

[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

So I did a step back to see if I can do a cURL request in a PHP script. I used the following script to try it (my company is using a proxy server with NTLM authentication):

$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);

And it worked fine.

What do I have to do to be able to install and use Symfony. Where do I define the proxy, the credentials and the NTLM method? I tried adding HTTP_PROXY in the env vars as "http://user:password@proxy.company.loc:8080", but that didn't help (maybe I also have to add the auth type NTLM somewhere).

The server is a Windows Server 2012 R2. PHP version is 5.6.5 and Apache is on 2.4.12.

Thanks for any help and sorry for any grammar errors!

解决方案

I will describe solution which I use myself.

  1. Download cntlm-0.92.3-setup.exe and install it (it will set up system service).
  2. Configure cntlm.ini (C:\Program Files (x86)\Cntlm\cntlm.ini) - proxy address, no proxy, domain account etc.
  3. Restart Cntlm Authentication Proxy service.
  4. Set http_proxy/https_proxy to http://localhost:3128 (system wide method)
  5. Try symfony installer now

Sometimes it could be a little bit slow but it works. I use this solution for all console apps that do not support integration with system wide proxy. Cntlm also works on unix based OS.

Hope that's help.

这篇关于在带有NTLM身份验证的代理服务器后面的Windows上安装Symfony的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆