首先準(zhǔn)備好自己下載的Tomcat7的綠色版,一定要是解壓的綠色版不能使exe安裝包。因?yàn)閑xe安裝版很多變量不好配置,我以前最喜歡exe版了,方便快捷,但是我發(fā)現(xiàn)還是綠色解壓版比較好,優(yōu)化配置等也很好上手。
下面有兩個(gè)文件非常重要,
1)C:\tomcat\apache-tomcat-7.0.41\conf\server.xml
這個(gè)文件主要是為了配置server shutdown端口號(hào)(<Server port="8305" shutdown="SHUTDOWN">)、http訪問端口號(hào)(<Connector port="8089")、以及Ajp端口( <Connector port="8229" protocol="AJP/1.3" ),只要這三個(gè)端口號(hào)在各個(gè)Tomcat解壓版的server.xml中不重復(fù)即可。
只要這三個(gè)端口號(hào)改ok了,就可以啟動(dòng)鳥??!運(yùn)行C:\tomcat\apache-tomcat-7.0.41\bin\startup.bat 即可。
實(shí)例配置8088和8089兩個(gè)tomcat服務(wù)器,找到server.xml下對(duì)應(yīng)的節(jié)點(diǎn)進(jìn)行修改
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
有的機(jī)器修改了上述server.xml三個(gè)端口號(hào)之后還是不能啟動(dòng),報(bào)錯(cuò):Neither the JAVA_HOME nor the JRE_HOME environment variable is defined,這是因?yàn)槟銢]有在setclasspath.bat里面定義好它的變量,有人在【我的電腦】--【右鍵屬性】--【環(huán)境變量】里面設(shè)置過,但是很遺憾,它不起作用,所以如下修改就ok了。
打開setclasspath.bat,在下面這個(gè)代碼(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
這樣就可以打開多個(gè)Tomcat版本了,同一臺(tái)機(jī)器。
主要問題:
在XP上明明已經(jīng)安裝了JDK1.5并設(shè)置好了JAVA_HOME,可偏偏Tomcat在啟動(dòng)過程中找不到。
1. 報(bào)錯(cuò)信息如下: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;提示找不到j(luò)ava_home各jre_home路徑,何解?
2.tomcat7w.exe打開后報(bào) : 指定的服務(wù)未安裝,指定的服務(wù)并未以已安裝的服務(wù)存在 Unable to open the Service 'tomcat7'
這個(gè)需要cmd 進(jìn)入 你的tomcat安裝目錄下的bin,然后輸入service.bat install就行了,奧,還有一點(diǎn),不用說直接打開文件夾,雙擊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
只能老老實(shí)實(shí)的:
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.