通过 composer 安装

composer require topthink/think-worker

启动

php think worker

初次使用可能会报错

[root@instance-jewlel2q www.imgram.cn]# php think worker
Starting Workerman http server...
Workerman[think] start in DEBUG mode
stream_socket_server() has been disabled for security reasons in file /home/wwwroot/www.imgram.cn/vendor/workerman/workerman/Worker.php on line 2178

原因是 stream_socket_server 函数被 php.ini 禁用

  • 运行 php –ini 找到 php.ini 文件
  • 打开 php.ini 找到 disable_functions 一项,将 stream_socket_server 禁用项删掉。
  • 重启 php-fpm。

发表评论

电子邮件地址不会被公开。 必填项已用*标注