drsrq26482 2015-03-03 06:10
浏览 57
已采纳

如何在AWS上将PHP脚本作为后台服务运行?

Now I am trying to execute php websocket script as a background. For it, I used below command on the AWS terminal.

php chat-server.php >> log.txt &

But strangely it is terminated without any errors.

My question is two.

  1. Why the php command is terminated on AWS? Is there any limitation to run a php script continually as a background service

  2. How can I run it permanently on AWS? I understand I can use a linux script to run my web-socket server permantely (maybe linux script will be re-lunch my php script when it will be terminated). But I don't know well linux commands. Who can help me?

Thanks for your advice!

  • 写回答

1条回答 默认 最新

  • douyu1990 2015-03-03 08:28
    关注

    First, enable PHP logs to see if there are any errors.

    Then, to run it permanently, you can use screen or Tmux. It's simple to use and lets you detach the process and run it in the background. So you are able to logout from your ssh session, and the process is still running.

    Please read:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突