PHP - 安装 Composer - 无法打开流:php_network_getaddresses: getaddrinfo failed: No such host is known
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14000646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP - Installing Composer - failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known
提问by Andrew Riker
I am attempting to use the Composer Dependency Managerfor PHP, but I am experiencing the following issue when I use the Composer-Setup.exe (Win32 installer).
我正在尝试使用Composer Dependency Managerfor PHP,但在使用 Composer-Setup.exe(Win32 安装程序)时遇到以下问题。
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
The download failed repeatedly, aborting.`
I followed the advice on several other stackoverflow threads for that error, and I've checked some other forums. In my php.ini, I have made sure I have the following options:
我遵循了关于该错误的其他几个stackoverflow线程的建议,并且我检查了其他一些论坛。在我的 php.ini 中,我确保我有以下选项:
allow_url_fopen = On
allow_url_include = On
extension=php_openssl.dll
I also tried the manual installationof Composer, which asks you to execute:
我也试过手动安装Composer,要求你执行:
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
I get the same error from that. However, If I remove "/installer", it can retrieve the source. I have verified that that the "/installer" URL works. What configuration could cause this behavior? I'm running PHP 5.4 on 32-bit Windows 7.
我从中得到了同样的错误。但是,如果我删除“/installer”,它可以检索源。我已验证“/installer” URL 是否有效。什么配置会导致这种行为?我在 32 位 Windows 7 上运行 PHP 5.4。
Thanks, Andrew
谢谢,安德鲁
采纳答案by Andrew Riker
This issue was actually the proxy variables. While the console was picking up the changes, PHP required a system restart to pick it up. So unsetting the environment variables and restarting allowed the Composer installer to retrieve the required files. Thanks Seldaek for your recommendation to check the proxy.
这个问题实际上是代理变量。当控制台接收更改时,PHP 需要重新启动系统才能接收更改。因此取消设置环境变量并重新启动允许 Composer 安装程序检索所需的文件。感谢 Seldaek 建议检查代理。
回答by Fred Ondieki
Solution 1
解决方案1
- Ensure you have connectivity try ping www.google.com
- 确保您有连接尝试 ping www.google.com
Solution 2
解决方案2
- Remove Proxy settings ,they could be ones causing it,if outside a corporate network
Solution 3
解决方案3
Add the corporate proxy setting if on a corporate network
- set http_proxy=http://your_proxy:your_port
- set http_proxy=http://username:password@your_proxy:your_port
- set https_proxy=https://your_proxy:your_port
- set https_proxy=https://username:password@your_proxy:your_port
如果在公司网络上,请添加公司代理设置
- 设置 http_proxy= http://your_proxy:your_port
- 设置 http_proxy= http://username:password@your_proxy:your_port
- 设置 https_proxy= https://your_proxy:your_port
- 设置 https_proxy= https://username:password@your_proxy:your_port
回答by thicy
mysqli_connect('root','', 'localhost', 'people');
You are passing root in as hostname.
您将 root 作为主机名传入。
try this
尝试这个
mysqli_connect('localhost','root', '', 'people');
this will connect to localhost with username root passwoord "" and default database people.
这将使用用户名 root 密码 "" 和默认数据库人员连接到本地主机。
maybe better to change localhost with 127.0.0.1
用 127.0.0.1 更改 localhost 可能更好


