简体   繁体   English

Composer在代理后面不起作用

[英]Composer doesn't work behind proxy

I'm trying to download Laravel on Ubuntu 16.04, but I'm having troubles trying to get Composer to work on our network. 我正在尝试在Ubuntu 16.04上下载Laravel,但是我在努力让Composer在我们的网络上工作时遇到了麻烦。 I believe that the issue is either related to our proxy server or a firewall, both of which (unfortunate) are managed by our parent organisation. 我认为问题与我们的代理服务器或防火墙有关,这两者(不幸)都是由我们的上级组织管理的。

I'm trying to run this command: 我正在尝试运行此命令:

sudo composer global require "laravel/installer"

Which gives me this error: 这给了我这个错误:

Changed current directory to /home/administrator/.composer

[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot assign requested address

require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

When I run composer diag , I get the following output: 当我运行composer diag时 ,我得到以下输出:

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot assign requested address
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot assign requested address
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" file could not be downloaded: failed to open stream: Connection refused
Checking disk free space: OK

Now, I've run this command to set the proxy: 现在,我运行此命令来设置代理:

export HTTP_PROXY="http://proxy.<url>:8080"

I've also modified /etc/profile to add in the following information: 我还修改了/ etc / profile以添加以下信息:

export HTTP_PROXY_REQUEST_FULLURI=0 # or false
export HTTPS_PROXY_REQUEST_FULLURI=0 #

And I've disabled ipv6 (in /etc/sysctl.conf ), as I noticed that has caused issues in the past: 我已经禁用ipv6(在/etc/sysctl.conf中 ),因为我注意到过去曾引起过问题:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1 

Which works (as apt-get uses it), but I can't seem to get curl to work at all. 哪个有用(就像apt-get使用它一样),但我似乎无法让curl工作。 Is there another variable that I should be setting? 我应该设置另一个变量吗?

您需要在SO中建立环境变量http_proxy = http:// username:password @ ip:port和https_proxy = http:// username:password @ ip:port

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM