一:檢驗系統是否已經安裝Tomcat環境:java
一、 檢測Tomcat是否已經安裝運行web
[UserName@localhost ~]$ ps -ef|grep tomcat UserName 2197 2182 0 08:59 pts/0 00:00:00 grep tomcat [UserName@localhost ~]$ apache |
這裏是tomcat未運行(若是能找到tomcat安裝路徑則可跳過第二步,也可根據本身須要的版本從新安裝tomcat)bootstrap
二:下載安裝Tomecat(在用戶下面配置Tomcat)tomcat
Tomcat的文件大小會隨着服務器的使用而日趨增大,建議將其安裝到home/用戶下去,爲了便於管理,在這裏咱們會新建一個文件夾,將Tomcat放在這個文件裏服務器
一、 新建文件夾(這裏新建了一個名爲apache的文件夾);app
[UserName@localhost ~]$ mkdir apachewebapp [UserName@localhost ~]$ cd apachesocket |
二、 下載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 ~]$ |
三、 減壓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]$ |
四、 管理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下的安裝就完成了。