阅读 102

tomcat变成服务

1在server.xml文件中依次查找并修改端口号:

 <Server port="8005" shutdown="SHUTDOWN">
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
复制代码

2修改service.bat文件(D:\TomcatServers\Tomcat1\bin\service.bat)该文件中共修改两处即可  

(1):在文件的开头加入以下设置,分别是java的安装路径、Tomcat的安装路径及服务的名称 Tomcat7替换Tomcat71 [plain] view plain copy SET JAVA_HOME=C:\java\jdk1.7.0_80 SET JRE_HOME=C:\java\jre7 SET CATALINA_HOME=C:\tomcat\apache-tomcat-7.0.88 SET PR_DISPLAYNAME=Apache Tomcat 7.0 Tomcat71 

(2):在文件中部找到以下内容并修改 [plain] view plain copy rem Set default Service name set SERVICE_NAME=Tomcat7 修改为 [plain] view plain copy rem Set default Service name set SERVICE_NAME=Tomcat71 set DISPLAYNAME=Apache Tomcat 7.0 Tomcat71 (3)、修改shutdown.bat和startup.bat文件(D:\TomcatServers\Tomcat1\bin\shutdown.bat|startup.bat)这两个文件修改的地方都相同在文件头加入以下内容即可 [plain] view plain copy SET JAVA_HOME=D:\TomcatServers\Tomcat1\java\jdk1.6.0 SET CATALINA_HOME=D:\TomcatServers\Tomcat1 3修改tomcat7.exe 为tomcat71.exe,tomcat7w.exe为tomcat71w.exe 4以管理员身份运行cmd cd C:\tomcat\apache-tomcat-7.0.88\bin d: .\service.bat install Apache Tomcat 7.0 Tomcat71 5删除服务关闭服务管理窗口后用sc delete Tomcat71 如果失败:Win+R regedit HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 路径下找到你的服务名(Tomcat71)..直接Delete 重启电脑.. 6控制台日志输出到文件 修改startup.bat第42行 call "%EXECUTABLE%" start %CMD_LINE_ARGS% 为 call "%EXECUTABLE%" run %CMD_LINE_ARGS% >> ..\logs\my.txt