WebSocket - Run PHP Daemon

The best way to run the PHP Daemon is thru SSH and with a Session. That way you have total control what is going on with the PHP Daemon and you can access the session any time you want.

First open a ssh tunnel to your server.

ssh ...

After you are connected with your server open a new session

screen -S livechat

Now we will run the php daemon inside the session livechat

/usr/local/bin/php /path_to_websocket/server/socketserver.php

Done! You should see following in the ssh window

Server Started: 2015-08-01 07:02:28
Master socket: Resource id #17
Listening on: lcsocket:9000

Master socket and listening will have a different value but now the server is running and ready to take some clients.

You can close ssh tunnel now, do not close the session livechat or the php daemon will shut down as well. You can always come back later and check how your PHP Dameon is behaving.

To detach the session press:

CTRL A and D

To check again, open the tunnel to your server and enter following in the ssh window

screen -rd livechat