首页 > PHP > PHP守护Linux/Unix进程

PHP守护Linux/Unix进程

2009年03月29号
查看评论 发表评论 1,686次浏览

  加上文件的可执行权限:
  $ chmod +x /home/heiyeluren/php_daemon2.php
  在服务器上执行命令:
  $ nohup /home/heiyeluren/php_daemon2.php &
  就进入了后台运行,我们通过Windows的客户端telnet上去:
  C:\>telnet 192.168.0.1 10000
  如果提示:
  正在连接到192.168.0.188…不能打开到主机的连接, 在端口 10000: 连接失败
  则说明服务器端没有开启,或者上面的程序没有正确执行,请检查php是否 –enable-sockets 功能。如果提示:
  ==========================================
  Welcome to the PHP Test Server.
  To quit, type ‘quit’.
  To shut down the server type ‘shutdown’.
  To get help message type ‘help’.
  ==========================================
  php>
  则说明顺利连接上了我们的PHP写的服务器端守护进程,在php>提示符后面能够执行help、quit、shutdown等三个命令,如果命令输入不是这三个,则提示:
  php> asdf
  PHP: unknow command ‘asdf’.
  执行help命令可以获取帮助
  php> help
  PHP Server Help Message
  To quit, type ‘quit’.
  To shut down the server type ‘shutdown’.
  To get help message type ‘help’.
  这个服务器端就不介绍了,可以自行扩展。
  杀进程跟例子一类似。
  [ 总结 ]通过以上学习,我们知道php也可以做守护进程,如果设计的好,功能也会比较强大,不过我们这里只是学习而已,可以自行研究更新。

页面: 1 2 3

类别PHP 标签
  1. pink balenciaga bag
    发表于 2010年06月18号 08时41分54秒 | 1楼

    i really enjoyed your post.

  2. puma future cat
    发表于 2010年06月21号 18时30分04秒 | 2楼

    ….interesting….

  3. Herve Leger Sale
    发表于 2010年06月22号 09时31分33秒 | 3楼

    Good grief!

  4. mbt lami
    发表于 2010年06月23号 10时52分34秒 | 4楼

    Thankyou for all your inspiration and for the goodness you spread.

  5. prada handbags
    发表于 2010年06月30号 11时10分59秒 | 5楼

    I have followed this one-year process through your editorials and articles. Thank you for your clear and reasonable position.

  6. Cheap Fake Mont Blanc Watches
    发表于 2010年07月02号 19时54分16秒 | 6楼

    it is such a colorful description.

  7. lebron shoes
    发表于 2010年07月19号 20时03分04秒 | 7楼

    this will be amazing

  8. 2010 New Herve Leger Dress
    发表于 2010年07月23号 10时18分30秒 | 8楼

    your words are just food for the soul! Fantastic!

  1. 目前没有通告
你必需 登陆 才能发表评论.