首页 > 网站 > Tomcat > 正文

手工把tomcat5安装成windows服务

2024-09-06 19:01:08
字体:
来源:转载
供稿:网友

由于习惯直接解压缩,然后拷贝整个tomcat到服务器上,因此需要手工把tomcat安装成windows服务;

利用以下脚本即可实现:
rem
rem nt service install/uninstall script
rem
rem options
rem install install the service using tomcat5 as service name.
rem service is installed using default settings.
rem remove – remove the service from the system.
rem
rem name (optional) if the second argument is present it is considered
rem to be new service name
rem
rem $id: service.bat,v 1.5 2004/04/08 16:49:37 mturk exp $
rem - — — — — — — — — — — — — — — — — — — — — — — — — — –
rem guess catalina_home if not defined
set current_dir=%cd%
if not "%catalina_home%" == "" goto gothome
set catalina_home=%cd%
if exist "%catalina_home%/bin/tomcat5.exe" goto okhome
rem cd to the upper dir
cd ..
set catalina_home=%cd%
:gothome
if exist "%catalina_home%/bin/tomcat5.exe" goto okhome
echo the tomcat.exe was not found…
echo the catalina_home environment variable is not defined correctly.
echo this environment variable is needed to run this program
goto end
:okhome
if not "%catalina_base%" == "" goto gotbase
set catalina_base=%catalina_home%
:gotbase

set executable=%catalina_home%/bin/tomcat5.exe

rem set default service name
set service_name=tomcat5

if "%1" == "" goto displayusage
if "%2" == "" goto setservicename
set service_name=%2
:setservicename
if %1 == install goto doinstall
if %1 == remove goto doremove
echo unknown parameter "%1"
:displayusage
echo
echo usage: service.bat install/remove [service_name]
goto end

:doremove
rem remove the service
"%executable%" //ds//%service_name%
echo the service '%service_name%' has been removed
goto end

:doinstall
rem install the service
rem use the environment variables as an exaple
rem each command line option is prefixed with pr_

set pr_displayname=apache tomcat
set pr_description=apache tomcat server – http://jakarta.apache.org/tomcat
set pr_install=%executable%
set pr_logpath=%catalina_home%/logs
set pr_classpath=%catalina_home%/bin/bootstrap.jar
"%executable%" //is//%service_name% --jvm %java_home%/jre/bin/server/jvm.dll --startclass org.apache.catalina.startup.bootstrap --stopclass org.apache.catalina.startup.bootstrap --startparams start --stopparams stop --stopmode jvm --startmode jvm
rem clear the environment variables. they are not needed any more.
set pr_displayname=
set pr_description=
set pr_install=
set pr_logpath=
set pr_classpath=
rem more extra parameters
set pr_stdoutput=%catalina_home%/logs/stdout.log
set pr_stderror=%catalina_home%/logs/stderr.log
"%executable%" //us//%service_name% --jvmoptions "-djava.io.tmpdir=%catalina_base%/;-dcatalina.home=%catalina_base%/;-djava.endorsed.dirs=%catalina_base%/common/endorsed/;"
echo the service '%service_name%' has been installed

:end
cd %current_dir%

在5.0.*测试通过

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表