首先准备好自己下载的Tomcat7的绿色版,一定要是解压的绿色版不能使exe安装包。因为exe安装版很多变量不好配置,我以前最喜欢exe版了,方便快捷,但是我发现还是绿色解压版比较好,优化配置等也很好上手。
下面有两个文件非常重要,
1)C:\tomcat\apache-tomcat-7.0.41\conf\server.xml
这个文件主要是为了配置server shutdown端口号(<Server port="8305" shutdown="SHUTDOWN">)、http访问端口号(<Connector port="8089")、以及Ajp端口( <Connector port="8229" protocol="AJP/1.3" ),只要这三个端口号在各个Tomcat解压版的server.xml中不重复即可。
只要这三个端口号改ok了,就可以启动鸟!!运行C:\tomcat\apache-tomcat-7.0.41\bin\startup.bat 即可。
实例配置8088和8089两个tomcat服务器,找到server.xml下对应的节点进行修改
1)8088
<Server port="8105" shutdown="SHUTDOWN">
<Connector port="8088" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
<Connector port="8109" protocol="AJP/1.3" redirectPort="8443" />
2)8089
<Server port="8205" shutdown="SHUTDOWN">
<Connector port="8089" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
<Connector port="8209" protocol="AJP/1.3" redirectPort="8443" />
2)C:\tomcat\apache-tomcat-7.0.41\bin\setclasspath.bat
有的机器修改了上述server.xml三个端口号之后还是不能启动,报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined,这是因为你没有在setclasspath.bat里面定义好它的变量,有人在【我的电脑】--【右键属性】--【环境变量】里面设置过,但是很遗憾,它不起作用,所以如下修改就ok了。
打开setclasspath.bat,在下面这个代码(rem In debug mode we need a real JDK (JAVA_HOME))后加入
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_10
set JRE_HOME=C:\Program Files\Java\jdk1.6.0_10
比如:
rem In debug mode we need a real JDK (JAVA_HOME)
if ""%1"" == ""debug"" goto needJavaHome
rem Otherwise either JRE or JDK are fine
变成了:
rem In debug mode we need a real JDK (JAVA_HOME)
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_10
set JRE_HOME=C:\Program Files\Java\jdk1.6.0_10
if ""%1"" == ""debug"" goto needJavaHome
rem Otherwise either JRE or JDK are fine
这样就可以打开多个Tomcat版本了,同一台机器。
主要问题:
在XP上明明已经安装了JDK1.5并设置好了JAVA_HOME,可偏偏Tomcat在启动过程中找不到。
1. 报错信息如下:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program;提示找不到java_home各jre_home路径,何解?
2.tomcat7w.exe打开后报 : 指定的服务未安装,指定的服务并未以已安装的服务存在 Unable to open the Service 'tomcat7'
这个需要cmd 进入 你的tomcat安装目录下的bin,然后输入service.bat install就行了,奥,还有一点,不用说直接打开文件夹,双击service.bat这种办法,不行的。
C:\>D:\apache-tomcat-7.0.41\bin\service.bat install
The tomcat.exe was not found...
The CATALINA_HOME environment variable is not defined correctly.
This environment variable is needed to run this program
只能老老实实的:
D:\apache-tomcat-7.0.41\bin>service.bat install
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Service will try to guess them from the registry.
Installing the service 'Tomcat7' ...
Using CATALINA_HOME: "D:\apache-tomcat-7.0.41"
Using CATALINA_BASE: "D:\apache-tomcat-7.0.41"
Using JAVA_HOME: ""
Using JRE_HOME: ""
Using JVM: "auto"
The service 'Tomcat7' has been installed.