Install Symfony on Windows behind proxy server wit

2019-07-17 18:04发布

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!

1条回答
甜甜的少女心
2楼-- · 2019-07-17 18:07

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.

查看更多
登录 后发表回答