setting up websockets without command line

maxhud picture maxhud · Feb 15, 2013 · Viewed 8.9k times · Source

How can I follow a tutorial like this without using the command line?

http://www.flynsarmy.com/2012/02/php-websocket-chat-application-2-0/

I need to be able to use websockets but have a shared server and no access to the command line.

I cannot simply run the script from a browser, if the script would stop running when i closed the browser/disconnected from the internet.

Answer

Octav O picture Octav O · Feb 22, 2013

Assuming your shared hosting provider supports crontab and cron jobs (most of them do), add the following job to the crontab:

@reboot nohup php /path/to/server.php 2>&1 >/dev/null &

Additionally, you need to start it now, so simply create the following PHP file and access it once, in your browser:

<?php shell_exec('nohup php /path/to/server.php 2>&1 > /dev/null &');?>

That should do the trick. Hopefully your shared hosting provider allows execve() calls to be made. Good luck!