Composer在代理后面不起作用

时间:2016-10-31 00:27:20

标签: php proxy composer-php ubuntu-16.04

我正在尝试在Ubuntu 16.04上下载Laravel,但我在努力让Composer在我们的网络上工作时遇到了麻烦。我认为该问题与我们的代理服务器或防火墙有关,这两者(不幸)都是由我们的上级组织管理的。

我正在尝试运行此命令:

sudo composer global require "laravel/installer"

这给了我这个错误:

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>]...

当我运行 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

现在,我运行此命令来设置代理:

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

我还修改了 / etc / profile 以添加以下信息:

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

我已经禁用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 

哪个有效(就像apt-get使用它一样),但我似乎根本无法工作。我应该设置另一个变量吗?

1 个答案:

答案 0 :(得分:0)

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