Starting/stopping Tomcat 使用 Wampserver 的按钮

Starting/stopping Tomcat using buttons of Wampserver

我安装了带有 Wampserver 2.0 的服务器,通过 mod_jk connector,我设法与 Tomcat 6 集成(作为 windows 服务安装)。为了方便起见,我对 wampmanager.ini 进行了一些更改,并且可以使用 WampServer 菜单启动所有服务。见下文:

[Services]
Name: wampapache
Name: wampmysqld
Name: Tomcat6

[StartupAction]
;WAMPSTARTUPACTIONSTART
Action: run; FileName: "D:/wamp/bin/php/php5.3.0/php-win.exe";Parameters: "refresh.php";WorkingDir: "D:/wamp/scripts"; Flags: waituntilterminated
Action: resetservices
Action: readconfig;
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors
;WAMPSTARTUPACTIONEND

[StartAll]
;WAMPSTARTALLSTART
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors
;WAMPSTARTALLEND

[StopAll]
;WAMPSTOPALLSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors
;WAMPSTOPALLEND

[RestartAll]
;WAMPRESTARTALLSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
;WAMPRESTARTALLEND

[myexit]
;WAMPMYEXITSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors
Action:  exit
;WAMPMYEXITEND

不过,我正在升级我的服务器,并尝试在Wampserver 3.0.0 中重复这个想法,但没有成功。 wampmanager.iniwampmanager.tpl(具有相同的设置部分),但是当使用菜单启动 Wampserver 时,Tomcat 服务不是开始了。

如果我手动启动 Tomcat 服务,集成工作正常,我唯一的问题是使用 WampServer 菜单单击即可启动和终止所有服务。

任何人都可以提出建议吗?

在Wampserver的论坛(read here)中交流信息后,成功解决了问题,在此分享我的问题解决方法。

与2.0版本不同,3.0.0版本没有在wampmanager.tpl中进行改动。更改说明如下:

$WAMP_HOME$\wampmanager.conf

在 [service] 标签中为 Tomcat 服务创建了一行(在我的例子中,Tomcat 8.0.30 作为服务安装,称为 'tomcat8')。

[service]
ServiceTomcat = "tomcat8"

$WAMP_HOME$\scripts\config.inc.php

为 Tomcat 服务创建变量

$c_tomcatService = $wampConf['ServiceTomcat']; 

$WAMP_HOME$\wampmanager.tpl

更改了上面原始 post 中提到的标签,添加了参考 Tomcat 服务的行

...
[Services]
Name: ${c_tomcatService}

...
[StartupAction]
Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors

...
[StartAll]
Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors

...
[StopAll]
Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors

...
[RestartAll]
Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated

...
[myexit]
Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors

在第一次测试中,没有用。我发现 Tomcat 服务由 Windows 服务管理器启动,但在通过提示手动调用或通过批处理文件(访问被拒绝错误)时无法正常工作,即使是服务器上的管理员。

Wampserver 的论坛建议我使用 SetACL (https://helgeklein.com)。使用以下命令,我能够更改权限:

setacl -on "tomcat8" -ot srv -ace "n:my_login;p:start_stop,read" -actn ace

使用此配置并使用 SetACL,我设法启动和停止 Tomcat 服务以及 Wampserver 的服务。