如何在 PHP 中启用 Socket?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1361925/
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
How to enable Socket in PHP?
提问by Fero
Could any one tell me how to enable SOCKET support in PHP ?
谁能告诉我如何在 PHP 中启用 SOCKET 支持?
回答by Sampson
This answer assumes you do have a php_sockets.dllextension file accessible (in your PHP installation extension directory or where required);
这个答案假设你有一个php_sockets.dll可访问的扩展文件(在你的 PHP 安装扩展目录中或需要的地方);
If you're using windows, just uncomment the following line in your php.inifile:
如果您使用的是 Windows,只需取消注释文件中的以下行php.ini:
;extension=php_sockets.dll
If you are missing the php_sockets.dll, you can download it from php.net.
如果您缺少php_sockets.dll,可以从php.net下载。
回答by Codler
The PHP Docker images come with 3 helper script commands that make installing and configuring extensions easier:
PHP Docker 映像附带 3 个帮助程序脚本命令,可以更轻松地安装和配置扩展:
docker-php-ext-configure: This command allows you to provide the custom arguments for an extension.docker-php-ext-install: Use this command to install new extensions in your container.docker-php-ext-enable: This command can be used to enable PHP extensions.
docker-php-ext-configure:此命令允许您为扩展提供自定义参数。docker-php-ext-install:使用此命令在您的容器中安装新扩展。docker-php-ext-enable: 此命令可用于启用 PHP 扩展。
Run
跑
docker-php-ext-install sockets
参考:https: //confluence.atlassian.com/bitbucket/php-with-bitbucket-pipelines-873907835.html#PHPwithBitbucketPipelines-InstallandenablePHPextensions
回答by soulmerge
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.
此处描述的套接字函数是 PHP 扩展的一部分,必须在编译时通过提供 --enable-sockets 选项进行配置来启用它。
From the extension's documentation.
来自扩展的文档。
回答by user889030
here are noobs instructions
这里是菜鸟说明
go to your php installation directory in windows it can be something like this c:\xampp\php
the goto ext direction in it php\ext\
- check if your have php_sockets.dllin that directory
- after that open php.inifile which will be in your php folder
- next search for
;extension=php_sockets.dll
转到您在 Windows 中的 php 安装目录,它可以是这样的c:\xampp\php
php\ext\ 中的 goto ext 方向
- 检查该目录中是否有php_sockets.dll
- 之后打开php.ini文件,该文件将位于您的 php 文件夹中
- 下次搜索
;extension=php_sockets.dll
if you find it then remove ;from it
如果你找到它然后;从中删除
if you not find it then search for extension=
如果你没有找到它然后搜索 extension=
and then below some extension add extension=php_sockets.dll
然后在一些扩展名下面添加 extension=php_sockets.dll
- and finally restart your apache.
- 最后重启你的apache。
回答by LAW WEI LIANG
For those of you that having this problem when installing RabbitMQ php library
对于那些在安装 RabbitMQ php 库时遇到此问题的人
Problem 1
问题一
- Installation request for php-amqplib/php-amqplib ^2.11 -> satisfiable by php- amqplib/php-amqplib[v2.11.0].
- php-amqplib/php-amqplib v2.11.0 requires ext-sockets * -> the requested PHP extension sockets is missing from your system.
- php-amqplib/php-amqplib ^2.11 -> php-amqplib/php-amqplib[v2.11.0] 可满足的安装请求。
- php-amqplib/php-amqplib v2.11.0 需要 ext-sockets * -> 您的系统中缺少请求的 PHP 扩展套接字。
Solution
解决方案
change ;extension=socketsto extension=socketsover php.init
更改;extension=sockets为extension=socketsphp.init
Notes:
笔记:
Not sockets.dll, only sockets
不是sockets.dll,只有sockets

