简体   繁体   English

如何打开远程服务器套接字的PHP?

[英]How to open remote server socket php?

I am developing chat application using php and ajax . 我正在使用php和ajax开发聊天应用程序。 later I found get messages by ajax after X seconds doesn't efficient. 后来,我发现X秒钟后Ajax收到消息效率不高。 I want to develop it by php socket . 我想通过php socket开发它。 I opened the local server socket by example : 我通过示例打开了本地服务器套接字:

php -f server.php 

My question is How can I open remote server socket after uploading files to the host, need to write commands ? 我的问题是将文件上传到主机后需要写命令时如何打开远程服务器套接字?

You can use same command in the remote server too if you have shell access to remote server. 如果您具有对远程服务器的外壳访问权限,则也可以在远程服务器中使用相同的命令。 Otherwise you have to run it using its URL. 否则,您必须使用其URL运行它。 If you have shell access and If you want it to run in background of the server just add && at the end like below in the terminal, 如果您具有外壳程序访问权限,并且希望它在服务器后台运行,则只需在终端中添加如下所示的&&,

php -f server.php &&

But this will not run again automatically after server reboot or after script stopped. 但这在服务器重新启动或脚本停止后不会自动再次运行。 If you want to do so, you need to use daemon process for this. 如果要这样做,则需要为此使用守护进程。 You can find information about daemon setup here 您可以在此处找到有关守护程序设置的信息

Run php script as daemon process 将PHP脚本作为守护进程运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM