我将用 php 编写我的第一个守护进程,我有几个非常基本的问题需要帮助。
-
需要什么包
安装在我的linux服务器上并且
PHP 中是否需要做任何事情
启用?到目前为止我已经得到了这个 -
http://pear.php.net/package/System_Daemon/download
-
我在服务器上的哪里保存我的
守护进程文件?
-
我有很多
需要包含的文件
在包含以下内容的守护进程内
聚会的班级和职能
通过 IMAP 发送电子邮件和附件。
所有这些文件当前都位于
我的网络公共目录,我该如何
在我的守护进程中包含这些文件吗?
我认为这就是我开始所需的一切。非常感谢!
I will be writing my first daemon in php and I have a couple really basic questions that I need help with.
-
What packages need to be
installed on my linux server and
Does anything in PHP need to be
enabled? So far I have gotten this -
http://pear.php.net/package/System_Daemon/download
-
Where on server do I save my
daemon files?
-
I have a number of
files that need to be included
within the daemon that contain
classes and functions for gathering
emails and attachments through IMAP.
All of these files are currently in
my web public directory, how do I
include these files within my daemon?
I think that is everything I need to get started. Thanks so much!
发布评论
评论(1)
只要你的php安装包括套接字,您将能够编写任何守护程序。
当前大多数 php 软件包都提供套接字支持。
您需要 shell 访问权限才能配置和执行您的守护程序,这不能通过将其作为 Web 应用程序提供来完成。
我不知道您提到的软件包,但它可能是一种让您更轻松地编写和维护守护程序的方法。
在任何地方,您只需要 shell 访问权限,如果您需要在 1024 以下的端口上启动它,您可能需要 root 权限。创建一个特殊用户,最终创建一个监狱,您可能会没事。
使用配置文件(例如 PHP 支持的 ini)来指定数据目录并从中读取。
进一步阅读:
As long your php installation includes sockets you'll be able to write any daemon.
Most of current php packages provides sockets support.
You need a shell access to be able to configure and execute your daemon, it won't be done by serving it as a web application.
I don't know about the package you mentioned but it's likely to be a way to make you easier to write and maintain your daemon.
Anywhere, you just need a shell access, you'll probably need root privileges, if you need to launch it on a port under 1024. Create a special user, eventualy make a jail, you'll probably be fine.
Use a config file, such as a ini which is supported by PHP to specify a data directory and read from.
Further reading :