设置没有命令行的websockets [英] setting up websockets without command line
问题描述
如何在不使用命令行的情况下遵循这样的教程?
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/
我需要能够使用websocket,但是必须具有共享服务器并且不能访问命令行.
I need to be able to use websockets but have a shared server and no access to the command line.
如果脚本在我关闭浏览器/与Internet断开连接后会停止运行,我不能简单地从浏览器中运行该脚本.
I cannot simply run the script from a browser, if the script would stop running when i closed the browser/disconnected from the internet.
推荐答案
假设您的共享托管服务提供商支持crontab和cron作业(大多数都支持),请将以下作业添加到crontab中:
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 &
此外,您需要立即启动它,因此只需创建以下PHP文件并在浏览器中对其进行一次访问即可:
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 &');?>
这应该可以解决问题.希望您的共享主机提供商允许进行 execve()调用.祝你好运!
That should do the trick. Hopefully your shared hosting provider allows execve() calls to be made. Good luck!
这篇关于设置没有命令行的websockets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!