1. 程式人生 > >Linux下tomcat無法啟動/啟動後無法用過127.0.0.1:8080訪問解決方案

Linux下tomcat無法啟動/啟動後無法用過127.0.0.1:8080訪問解決方案

clas java require com 自己的 bug jpda force comm

啟動tomcat情況如下:

[email protected]:/usr/local/tomcat/apache-tomcat-8.5.20/bin# ./catalina.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.20
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.20
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.20/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_144
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.20/bin/tomcat-juli.jar
Usage: catalina.sh ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina, waiting up to 5 seconds for the process to end
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
configtest Run a basic syntax check on server.xml - check exit code for result
version What version of tomcat are you running?


Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined

在一個網站上看到說這個是因為環境變量的問題,tomcat使用的環境變量是自己的或者是繼承自當前用戶的,所以在Linux裏面即使你設置了java_home也不一定會用這個,所以要麽你都繼承root的環境變量,都統一起來確保你的系統裏面的環境變量都是使用的同一個,要麽就單獨指定要使用的jdk。tomcat啟動的時候需要盜用setclasspath.sh。只要在setclasspath.sh聲明環境變量就可以知道你這個tomcat使用哪個jdk,打開tomcat的bin目錄下面的setclasspath.sh,添加上,路徑自己修改,添加在開頭就行

export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export JRE_HOME=/usr/local/java/jdk1.8.0_144/jre

然後重啟tomcat就可以使用了

Linux下tomcat無法啟動/啟動後無法用過127.0.0.1:8080訪問解決方案