在Digital Ocean

时间:2017-12-10 09:10:48

标签: composer-php ubuntu-16.04 digital-ocean

我能够进入我的小滴。我也能够更新和升级。

当我尝试运行sudo composer self-update或composer update时,我收到连接超时错误。

The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out  

ufw status

的输出
To      Action    From
22      ALLOW     Anywhere
80      ALLOW     Anywhere
443     ALLOW     Anywhere
25      ALLOW     Anywhere
10000   ALLOW     Anywhere     

composer diagnose

的输出
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: Connection timed out
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file    could not be downloaded: failed to open stream: Connection timed out
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: 

[Composer\Downloader\TransportException]                                     
The "https://getcomposer.org/version" file could not be downloaded: failed   
to open stream: Connection timed out

composer --version

的输出
Composer version 1.0-dev (9e9c1917e1ed9f3f78b195a785aee3c6dc3cb883) 2015-11-23 10:31:23  

curl IL http://packagist.org/packages.json

的输出
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 10 Dec 2017 08:40:20 GMT
Content-Type: application/json
Content-Length: 1302
Last-Modified: Sun, 10 Dec 2017 08:38:28 GMT
Connection: keep-alive
ETag: "5a2cf284-516"
Cache-Control: private, max-age=0, no-cache
Accept-Ranges: bytes  

我试图手动获取最新作曲家的副本,但它也不起作用

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

的输出
PHP Warning:  copy(https://getcomposer.org/installer): failed to open stream: Connection timed out in Command line code on line 1  

可能是什么原因?大约一个星期前我一直都在工作。我可以访问(浏览)我的droplett上托管的网页。我也能够更新和升级。

4 个答案:

答案 0 :(得分:3)

您可以以root身份运行此命令,使IPV4优于IPV6:

sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"

答案 1 :(得分:1)

https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues-可以解决您的问题。如果composer update之后变慢,请尝试使用更新的PHP版本运行它。使用PHP 7而不是PHP 5运行它将导致大的加速

答案 2 :(得分:0)

我也发现了上一次关于此超时的执行composer命令的错误。运行“ compose diag”,然后重新启动命令,以解决与ipv6不相关的问题

答案 3 :(得分:0)

我的问题是由PHP 7.2引起的,切换回PHP 7.1'sphp 7.1'后,再次运行命令'composer update',它可以正常工作