我正在尝试在 Windows Server 2008 SP1 机器上设置 PHP Web 应用程序。我们让这个应用程序在 Windows Server 2003 上正确运行,但现在无法PHP
正确启动使用 php_win32service 扩展构建的 Windows 服务。
以下是PHP
代码的相关部分。这是执行安装和卸载的部分:
if ($argv[1] == 'install') {
win32_create_service(array(
'service' => $service_name,
'display' => $service_name,
'params' => '"'. __FILE__ . '"' . ' run'));
exit;
}
else if ($argv[1] == 'uninstall') {
win32_delete_service($service_name);
exit;
}
else if ($argv[1] != 'run') {
die("Invalid arguments");
}
win32_start_service_ctrl_dispatcher($service_name);
这是主循环:
while (1) {
switch (win32_get_last_control_message()) {
case WIN32_SERVICE_CONTROL_INTERROGATE: win32_set_service_status(WIN32_SERVICE_RUNNING); break; // Respond with status
case WIN32_SERVICE_CONTROL_STOP: win32_set_service_status(WIN32_SERVICE_STOPPED); exit; // Terminate script
}
processQueue();
usleep(500000);
}
只要我cmd
以管理员身份运行,安装和卸载就可以工作。如果我cmd
在用于登录服务器的帐户下启动,则不会创建服务win32_create_service
。我也可以使用run
命令行中的参数运行脚本并且它运行正确,但是当我尝试启动服务时,它只是挂起Starting
消息并且永远不会进入Started
状态。
I think this issue has something to do with the rights of the LocalSystem
account on the machine, but I do not know what rights are needed to get this to work properly. I also do not know how I can debug this and find out what error/issue is occurring with the WIN32_SERVICE_CONTROL_INTERROGATE
, especially as I do not have rights on this server to make changes to security settings. Any changes that I need made to security settings I need to communicate to the network administrator so that he can perform the changes. Can anyone offer any help with debugging or resolving this issue?
UPDATE:
This issue only seems to occur in the 64-bit version of PHP
. It seems that the 64-bit compile of php_win32service
runs into some sort of problem when trying to start the service. I removed the 64-bit versions of PHP
and 'php_win32service' and replaced them with the 32-bit versions. The service then started correctly.