php7.4 连接rabbitmq 报stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Try again 错误位置
除了安装扩展amqp,sockets还要将allow_url_fopen 和 allow_url_include打开
一、
还要查看 PHP 配置中 `allow_url_fopen` 和 `allow_url_include` 的值,可以使用以下方法:
1. 创建一个 PHP 文件,比如`phpinfo.php`,并在文件中写入以下代码:
php
<?php
phpinfo();
?>
打开的页面中,你将看到所有关于 PHP 配置和环境的信息。使用浏览器搜索功能(通常是按下 Ctrl + F 键),搜索`allow_url_fopen`和`allow_url_include`。
2. 在搜索结果中,你将看到这两个配置项的值。它们通常以 "On" 或 "Off" 来表示。如果 `allow_url_fopen` 是 "On",则表示允许使用 `fopen()` 函数打开远程 URL。如果 `allow_url_include` 是 "On",则表示允许使用 `include()` 和 `require()` 函数加载远程文件。
二、
还有可能报Call to undefined function PhpAmqpLib\Wire\bcadd() 错误信息
如果在使用 `PhpAmqpLib` 库时出现 "Call to undefined function PhpAmqpLib\Wire\bcadd()" 的错误,这是因为你的 PHP 环境缺少 `bcmath` 扩展导致的。
在dnmp 集成环境中只需安装bcmath扩展文件即可
方法:在.env配置文件中,PHP_EXTENSIONS后面加上bcmath,重新构建php