qq_22237055 2019-08-27 15:35 采纳率: 0%
浏览 643

重新composer 后,使用是出现超时错误?

今天重装了composer,重装后使用时出现超时错误如下

qi@qi-ideacentre-AIO-300-23ISU:/var/www/html$ composer create-project --prefer-dist laravel/laravel blog


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

使用过composer中国镜像,然而报错信息与之前一模一样。

运行环境如下
ubuntu 16.04.1
php 7.1
composer 1.9

composer config如下

[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://packagist.phpcomposer.com
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (/var/www/html/vendor)
[bin-dir] {$vendor-dir}/bin (/var/www/html/vendor/bin)
[cache-dir] /home/qi/.cache/composer
[data-dir] /home/qi/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/home/qi/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/home/qi/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/home/qi/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[bin-compat] auto
[discard-changes] false
[autoloader-suffix] 
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile] 
[capath] 
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[home] /home/qi/.config/composer

附加信息:报错信息中的https://repo.packagist.org/packages.json在我的浏览器上是能打开的,域名也能ping通

qi@qi-ideacentre-AIO-300-23ISU:/var/www/html$ ping repo.packagist.org
PING repo.packagist.org (54.38.136.239) 56(84) bytes of data.
64 bytes from ip-54-38-136.eu (54.38.136.239): icmp_seq=1 ttl=39 time=362 ms
64 bytes from ip-54-38-136.eu (54.38.136.239): icmp_seq=2 ttl=39 time=371 ms
64 bytes from ip-54-38-136.eu (54.38.136.239): icmp_seq=3 ttl=39 time=391 ms
64 bytes from ip-54-38-136.eu (54.38.136.239): icmp_seq=4 ttl=39 time=359 ms
^C
--- repo.packagist.org ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4002ms
rtt min/avg/max/mdev = 359.543/371.305/391.974/12.752 ms
  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-31 11:51
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    这个问题可能由多种原因引起。以下是一些可能导致composer下载文件失败的原因:

    1. 网络问题:你的服务器或网络连接可能存在问题,导致无法访问composer仓库。尝试检查你的网络连接,并确保你的服务器可以正常通信。

    2. 防火墙设置:某些防火墙规则可能会阻止composer从特定的URL下载文件。你可以通过在终端中执行sudo ufw allow <packagist-url>来允许这些请求。

    3. PHP版本问题:如果你的PHP版本不支持composer,那么你将无法安装依赖包。确保你的PHP版本已经正确安装并满足要求。

    4. Composer版本问题:如果你的composer版本过旧,它可能不会支持新的API或特性。尝试更新到最新的composer版本。

    5. 权限问题:你可能没有足够的权限去下载文件。确保你有足够的权限去操作文件夹和目录。

    6. 缓存问题:有时,由于缓存的问题,composer可能会遇到超时问题。清理你的Composer缓存并重新运行命令应该能够解决这个问题。

    如果你仍然遇到问题,建议你查看Composer的官方文档,或者联系Composer团队寻求帮助。他们通常会提供更具体的解决方案。

    评论

报告相同问题?