我尝试使用命令安装Laravel," sudo composer create-project laravel / laravel my_project --prefer-dist ",但我保留得到错误:
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Network is unreachable
要查看一切是否正常,我运行了命令," composer diagnose "得到以下输出:
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking HTTP proxy: OK
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.6.5
PHP version: 7.0.28-0ubuntu0.16.04.1
PHP binary path: /usr/bin/php7.0
除了第一项之外的一切都很好。
使用" curl https://packagist.org/packages.json "测试网络元素,显示文件内容:
{"packages":[],"notify":"\/downloads\/%package%","notify-batch":"\/downloads\/","providers-url":"\/p\/%package%$%hash%.json","search":"\/search.json?q=%query%&type=%type%","provider-includes":{"p\/provider-2013$%hash%.json":{"sha256":"e8a58721d48f09fca4bf257fac28558dc991cef7b48c19788e27bff3a99281d4"},"p\/provider-2014$%hash%.json":{"sha256":"b6bc409a370dc08774a2843e4bbf3361673fc5bc70bed785ebdeda390ba346b3"},"p\/provider-2015$%hash%.json":{"sha256":"a8672ac6b29efa52ebd0cd4e4eb96c501fd53cfe3210f840b16d6e9c94323db4"},"p\/provider-2016$%hash%.json":{"sha256":"71c329389ec4548f58a929bb7247bda62442620297b90cb78436de5782eed151"},"p\/provider-2017$%hash%.json":{"sha256":"b080b76a6d9a2f0894c34e9e49bcfa97a746a45b070e4a6db7703241bf11dd66"},"p\/provider-2017-07$%hash%.json":{"sha256":"070467a6b8731c1ad87e110ebcf4aad74fc772f57ac5fe06a22714732e4d2ec8"},"p\/provider-2017-10$%hash%.json":{"sha256":"9f61c57bba06ec280de49be57bba3f6ce133c2bd1de7252d7e8ff7749519cadf"},"p\/provider-2018-01$%hash%.json":{"sha256":"461f6ba8553b9eb3ca1ffcabcf396c94ca2147b497f2d7db859e85749b2912b5"},"p\/provider-2018-04$%hash%.json":{"sha256":"c7cfb560ab198f3194b37a9acbb2b489a45cf48d269ac388a7b862884ad050d3"},"p\/provider-archived$%hash%.json":{"sha256":"afa373e95aa9fa7678612f8c7a961c6373160760005c1f8f41450f2860d933f9"},"p\/provider-latest$%hash%.json":{"sha256":"df4817874d00dfdd1d46dc2c1d92cd77aac2b9178a2115339e8978ee8652fca7"}}}
理论上证明网络和服务器可以看到实际文件。我还通过export命令设置了HTTP和HTTPS代理到公司的代理。
我已经修改了IPv4高于IPv6的优先级。
跑步"作曲家clearcache"在上述命令没有任何区别之前,也没有更改packagist的存储库。
运行命令" curl -sS https://getcomposer.org/installer | php - --check "再次返回输出:
All settings correct for using Composer
有没有人知道我可以做些什么来尝试让这个工作?它仍然是一个网络问题,我不确定Composer正在尝试使用哪个流。
感谢您就此问题提供任何意见。
答案 0 :(得分:1)
上面的问题是在环境中设置了一些HTTP_PROXY值之后,尽管运行了在当前实例中设置它们的命令,但它们没有采用。
关闭会话并重新启动它会使环境变量发挥作用,我能够成功安装Laravel!