tomcat是隨機啟動的,所以在開啟伺服器的時候要手動開啟tomcat,不然沒法訪問(網上說可以設定隨著伺服器開啟而開啟,我還不會妮。。。)
1:找到tomcat安裝路徑
[root@localhost ~]# cd .. (返回上一級目錄)
[root@localhost /]# ls (列出該目錄下的所有檔案)
bin dev home lib64 media mnt opt root selinux sys tmp var
boot etc lib lost+found misc net proc sbin srv tftpboot usr
[root@localhost /]# cd var (開啟var這個檔案夾)
[root@localhost var]# ls (查看該檔案的列表)
account crash empty gdm local mail opt run tux
arpwatch cvs ftp kerberos lock named preserve spool www
cache db games lib log nis racoon tmp yp
(看來不在var檔案夾中,只能返回上一級目錄)
[root@localhost var]# cd ..
[root@localhost /]# cd usr
[root@localhost usr]# ls
2.sql
etc java lib64 sbin tmp
apache-tomcat-7.0.14.tar games kerberos libexec share tomcat7.0
bin include lib local src X11R6
[root@localhost usr]# cd tomcat7.0 (開啟tomcat7.0這個檔案夾)
[root@localhost tomcat7.0]# ls
bin hsperfdata_root LICENSE NOTICE RUNNING.txt webapps
conf lib logs RELEASE-NOTES temp work
[root@localhost tomcat7.0]# cd bin
[root@localhost bin]# ls
bootstrap.jar configtest.sh setclasspath.sh tomcat-native.tar.gz
catalina.bat cpappend.bat shutdown.bat tool-wrapper.bat
catalina.sh d: shutdown.sh tool-wrapper.sh
catalina-tasks.xml digest.bat startup.bat version.bat
commons-daemon.jar digest.sh startup.sh version.sh
commons-daemon-native.tar.gz setclasspath.bat tomcat-juli.jar
[root@localhost bin]# ./ (目前的目錄,這裡是做什麼用的,不太清楚。。。)
-bash: ./: is a directory
[root@localhost bin]# ./startup.sh (啟動Tomcat)
Using CATALINA_BASE: /usr/tomcat7.0
Using CATALINA_HOME: /usr/tomcat7.0
Using CATALINA_TMPDIR: /usr/tomcat7.0
Using JRE_HOME: /usr/java/jdk1.6.0_24
Using CLASSPATH: /usr/tomcat7.0/bin/bootstrap.jar:/usr/tomcat7.0/bin/tomcat-juli.jar
啟動成功
2:查看tomcat的日誌
[root@localhost bin]# cd ..
[root@localhost tomcat7.0]# ls
bin hsperfdata_root LICENSE NOTICE RUNNING.txt webapps
conf lib logs RELEASE-NOTES temp work
[root@localhost tomcat7.0]# cd logs (開啟記錄檔夾)
[root@localhost logs]# ls
catalina.2011-05-30.log localhost.2011-06-28.log
catalina.out localhost_access_log.2011-06-27.txt
host-manager.2011-05-30.log localhost_access_log.2011-07-07.txt
(沒用的不貼了)
[root@localhost logs]# tail -f catalina.out (查看tomcat的記錄檔)
ps:Linux下Tomcat的啟動、關閉、殺死進程
cd /java/tomcat
#執行
bin/startup.sh #啟動tomcat
bin/shutdown.sh #停止tomcat
tail -f logs/catalina.out #看tomcat的控制台輸出;
#看是否已經有tomcat在運行了
ps -ef |grep tomcat
#如果有,用kill;
kill -9 pid #pid 為相應的進程號
例如 ps -ef |grep tomcat 輸出如下
sun 5144 1 0 10:21 pts/1 00:00:06 /java/jdk/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/java/tomcat/common/endorsed -classpath :/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/java/tomcat -Dcatalina.home=/java/tomcat -Djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap start
則 5144 就為進程號 pid = 5144
kill -9 5144 就可以徹底殺死tomcat
#直接查看指定連接埠的進程pid
netstat -anp|grep 9217
#結果為 tcp 0 0 :::9217 :::*
LISTEN 26127/java
#則26127為9217這個連接埠的tomcat進程的pid,然後就可以kill這個進程
kill -9 26127
#然後再啟動tomcat即可