下载 Laravel 安装程序时连接被拒绝 - "https://repo.packagist.org/packages.json" 文件无法下载”

Connection refused while downloading Laravel installer - "https://repo.packagist.org/packages.json" file could not be downloaded"

我第一次尝试使用 Composer 下载 Laravel 安装程序 Ubuntu 20.04 LTS

composer global require laravel/installer

给予

Changed current directory to /home/sandeep/.config/composer

In RemoteFilesystem.php line 560:
                                                                                                           
  The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection refused

                                                                                      

PHP 版本:

PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

作曲家版本

Composer 1.10.1 2020-03-13 20:34:27  

Ping 输出:

sandeep@sandeep:~$ ping repo.packagist.org
PING org.domain.name (78.47.226.171) 56(84) bytes of data.
64 bytes from static.171.226.47.78.clients.your-server.de (78.47.226.171): icmp_seq=1 ttl=49 time=251 ms
64 bytes from static.171.226.47.78.clients.your-server.de (78.47.226.171): icmp_seq=2 ttl=49 time=251 ms
64 bytes from static.171.226.47.78.clients.your-server.de (78.47.226.171): icmp_seq=3 ttl=49 time=251 ms
64 bytes from static.171.226.47.78.clients.your-server.de (78.47.226.171): icmp_seq=4 ttl=49 time=251 ms
64 bytes from static.171.226.47.78.clients.your-server.de (78.47.226.171): icmp_seq=5 ttl=49 time=251 ms
^C
--- org.domain.name ping statistics ---
6 packets transmitted, 5 received, 16.6667% packet loss, time 5007ms
rtt min/avg/max/mdev = 250.508/250.803/251.168/0.231 ms

不确定这是配置问题、网络问题还是其他问题。

这是一个网络问题。

我不得不修改/etc/resolv.conf

sudo vim /etc/resolv.conf

并添加

nameserver 8.8.8.8
nameserver 8.8.4.4

保存文件并重启网络。