簡體   English   中英

在具有NTLM身份驗證的代理服務器后面的Windows上安裝Symfony

[英]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。

感謝您的幫助,對於任何語法錯誤,我們深表歉意!

我將描述自己使用的解決方案。

  1. 下載cntlm-0.92.3-setup.exe並進行安裝(它將設置系統服務)。
  2. 配置cntlm.ini(C:\\ Program Files(x86)\\ Cntlm \\ cntlm.ini)-代理地址,無代理,域帳戶等
  3. 重新啟動Cntlm身份驗證代理服務。
  4. 將http_proxy / https_proxy設置為http:// localhost:3128 (系統范圍的方法)
  5. 立即嘗試symfony安裝程序

有時可能會有點慢,但可以。 我將這種解決方案用於所有不支持與系統范圍代理集成的控制台應用程序。 Cntlm也可以在基於unix的OS上工作。

希望對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM