workerman啟動(dòng)錯(cuò)誤解決方法

workerman啟動(dòng)錯(cuò)誤解決方法

現(xiàn)象1:

啟動(dòng)后報(bào)錯(cuò)類似如下:

php start.php start PHP Warning:  stream_socket_server(): unable to connect to tcp://xx.xx.xx.xx:xxxx (Address already in use) in /home/workerman-chat/Workerman/Worker.php on line xxxx

關(guān)鍵字: Address already in use

失敗原因:

端口被占用,無(wú)法啟動(dòng)。

可以通過(guò)命令netstat -anp | grep 端口號(hào)來(lái)找出哪個(gè)程序占用了端口。

然后停止對(duì)應(yīng)的程序釋放端口解決。

如果不能停止對(duì)應(yīng)端口的程序,可以通過(guò)更換workerman的端口解決。

如果是Workerman占用的端口,又無(wú)法通過(guò)stop命令停止(一般是丟失pid文件或者主進(jìn)程被開(kāi)發(fā)者kill了導(dǎo)致),可以通過(guò)運(yùn)行以下兩個(gè)命令殺死Workerman進(jìn)程。

killall php ps aux|grep WorkerMan|awk '{print $2}'|xargs kill -9

現(xiàn)象2

啟動(dòng)后報(bào)錯(cuò)類似如下:

PHP Warning:  stream_socket_server(): unable to connect to tcp://xx.xx.xx.xx:xxx (Cannot assign requested address) in /home/GatewayWorker/Workerman/Worker.php on line xxxx

關(guān)鍵字:Cannot assign requested address

失敗原因:

啟動(dòng)腳本ip參數(shù)寫錯(cuò),不是本機(jī)ip,請(qǐng)?zhí)顚懕緳C(jī)ip機(jī)或者填寫 0.0.0.0(表示監(jiān)聽(tīng)本機(jī)所有ip)即可解決。

提示:linux系統(tǒng)可以通過(guò)命令 ifconfig查看本機(jī)所有網(wǎng)卡ip。

如果您是騰訊云用戶,注意您的公網(wǎng)ip實(shí)際是代理服務(wù)器ip,公網(wǎng)ip并不屬于你的服務(wù)器,所以無(wú)法通過(guò)公網(wǎng)ip綁定,但是可以通過(guò)0.0.0.0來(lái)綁定。

現(xiàn)象3

Waring stream_socket_server has been disabled for security reasons in ...

失敗原因:

stream_socket_server 函數(shù)被php.ini禁用

解決方法

1、運(yùn)行php –ini 找到php.ini文件

2、打開(kāi)php.ini找到disable_functions一項(xiàng),將stream_socket_server禁用項(xiàng)刪掉

現(xiàn)象4

PHP Warning:  stream_socket_server(): unable to connect to tcp://0.0.0.0:xxx (Permission denied)

失敗原因

linux下監(jiān)聽(tīng)端口如果小于1024,需要root權(quán)限。

解決辦法

使用大于1024的端口或者使用root用戶啟動(dòng)服務(wù)。

推薦:workerman教程

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊7 分享