使用Wampserver按钮启动/停止Tomcat

时间:2016-02-19 18:20:01

标签: tomcat wamp wampserver tomcat8

我安装了一个带有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.ini 中引用了这些更改 和 wampmanager.tpl (它们具有相同的部分进行设置),但在使用菜单时,例如,启动Wampserver,Tomcat服务未启动。

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

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

1 个答案:

答案 0 :(得分:0)

在Wampserver论坛(read here)交换信息后,设法解决问题,我在这里分享我的问题的解决方案。

与2.0版本不同, wampmanager.tpl 中不会进行3.0.0版本更改。更改如下所述:

<强> $ WAMP_HOME $ \ wampmanager.conf

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

[service]
ServiceTomcat = "tomcat8"

<强> $ WAMP_HOME $ \脚本\的config.inc.php

为Tomcat服务创建变量

$c_tomcatService = $wampConf['ServiceTomcat']; 

<强> $ WAMP_HOME $ \ wampmanager.tpl

更改了上面原帖中提到的标记,添加了参考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的服务。