一:检验系统是否已经安装Tomcat环境:
1、 检测Tomcat是否已经安装运行
[UserName@localhost ~]$ ps -ef|grep tomcat
UserName 2197 2182 0 08:59 pts/0 00:00:00 grep tomcat
[UserName@localhost ~]$
|
这里是tomcat未运行(如果能找到tomcat安装路径则可跳过第二步,也可根据自己需要的版本重新安装tomcat)
二:下载安装Tomecat(在用户下面配置Tomcat)
Tomcat的文件大小会随着服务器的使用而日趋增大,建议将其安装到home/用户下去,为了便于管理,在这里我们会新建一个文件夹,将Tomcat放在这个文件里
1、
新建文件夹(这里新建了一个名为apache的文件夹);
[UserName@localhost ~]$ mkdir
apache
[UserName@localhost ~]$
cd apache
|
2、
下载Tomcat:
[UserName@localhost ~]$ wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-6/v6.0.39/bin/apache-tomcat-6.0.39.tar.gz
--2014-02-22 09:51:42-- http://mirrors.cnnic.cn/apache/tomcat/tomcat-6/v6.0.39/bin/apache-tomcat-6.0.39.tar.gz
Resolving mirrors.cnnic.cn... 123.125.244.87
Connecting to mirrors.cnnic.cn|123.125.244.87|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7065481 (6.7M) [application/x-gzip]
Saving to: “apache-tomcat-6.0.39.tar.gz”
100%[======================================>] 7,065,481 1.49M/s in 4.8s
2014-02-22 09:51:47 (1.40 MB/s) - “apache-tomcat-6.0.39.tar.gz” saved [7065481/7065481]
[UserName@localhost ~]$
|
3、
减压Tomcat
[UserName@localhost ~]$
tar -xzvf apache-tomcat-6.0.39.tar.gz
apache-tomcat-6.0.39/webapps/manager/images/code.gif
apache-tomcat-6.0.39/webapps/manager/images/design.gif
apache-tomcat-6.0.39/webapps/manager/images/docs.gif
…………
apache-tomcat-6.0.39/webapps/manager/images/fix.gif
apache-tomcat-6.0.39/webapps/manager/images/tomcat.gif
apache-tomcat-6.0.39/webapps/manager/images/update.gif
apache-tomcat-6.0.39/webapps/manager/images/void.gif
apache-tomcat-6.0.39/webapps/manager/status.xsd
apache-tomcat-6.0.39/webapps/manager/xform.xsl
[UserName@localhost apache]$
|
4、
管理Tomcat(开启,关闭,关闭线程)
①
先检查Tomcat是否已经运行
[UserName@localhost ~]$ ps -ef|grep tomcat
UserName 2197 2182 0 08:59 pts/0 00:00:00 grep tomcat
[UserName@localhost ~]$
|
②
进去Tomcat文件夹
[UserName@localhost ~]$ cd apache/apache-tomcat-6.0.39/
|
③
开启Tomcat
[UserName@localhost apache-tomcat-6.0.39]$ bin/startup.sh
Using CATALINA_BASE: /home/admin/apache/apache-tomcat-6.0.39
Using CATALINA_HOME: /home/admin/apache/apache-tomcat-6.0.39
Using CATALINA_TMPDIR: /home/admin/apache/apache-tomcat-6.0.39/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/admin/apache/apache-tomcat-6.0.39/bin/bootstrap.jar
[UserName@localhost apache-tomcat-6.0.39]$
|
④
检验Tomcat是否开启
[UserName@localhost apache-tomcat-6.0.39]$ ps -ef | grep tomcat
UserName 3552 1 2 17:07 pts/0 00:00:04 /usr/bin/java -Djava.util.logging.config.file=/home/admin/apache/apache-tomcat-6.0.39/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/admin/apache/apache-tomcat-6.0.39/endorsed -classpath /home/admin/apache/apache-tomcat-6.0.39/bin/bootstrap.jar -Dcatalina.base=/home/admin/apache/apache-tomcat-6.0.39 -Dcatalina.home=/home/admin/apache/apache-tomcat-6.0.39 -Djava.io.tmpdir=/home/admin/apache/apache-tomc
at-6.0.39/temp org.apache.catalina.startup.Bootstrap start
UserName 3578 2264 0 17:10 pts/0 00:00:00 grep tomcat
[UserName@localhost apache-tomcat-6.0.39]$
|
⑤
关闭Tomcat
[UserName@localhost apache-tomcat-6.0.39]$ bin/shutdown.sh
Using CATALINA_BASE: /home/admin/apache/apache-tomcat-6.0.39
Using CATALINA_HOME: /home/admin/apache/apache-tomcat-6.0.39
Using CATALINA_TMPDIR: /home/admin/apache/apache-tomcat-6.0.39/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/admin/apache/apache-tomcat-6.0.39/bin/bootstrap.jar
[UserName@localhost apache-tomcat-6.0.39]$
|
四: Tomecat启动异常错误排查:
①
路径是否正确
解决方法:检查路径是否正确
[UserName@localhost apache-tomcat-6.0.39]$ pwd
/home/admin/apache/apache-tomcat-6.0.39
|
②
端口是否被占用
解决方法:
查看tomcat工作日志(查看logs文件夹下的catalina.out日志)
[UserName@localhost logs]$ tail -f -n 50 catalina.out
Feb 21, 2014 5:32:42 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:406)
at org.apache.catalina.startup.Catalina.await(Catalina.java:676)
at org.apache.catalina.startup.Catalina.start(Catalina.java:628)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Feb 22, 2014 5:32:42 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Feb 22, 2014 5:32:43 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Feb 22, 2014 5:32:43 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
|
显示地址已经被占用,修改tomcat默认端口
用编辑器打开conf下面的server.xml文件
[UserName@localhost ~]$ cd apache/apache-tomcat-6.0.39/
[UserName@localhost apache-tomcat-6.0.39]$ vi conf/server.xml
|
修改三个端口,使两个tomcat的三个端口都不重复,再次启动Tomecat(也可将server.xml下载下来修改完后直接覆盖该文件)
Tomecat在Linux下的安装就完成了。