红联Linux门户
Linux帮助

Linux下tomcat无法启动/启动后无法用127.0.0.1:8080访问的解决

发布时间:2017-08-27 10:44:14来源:linux网站作者:rogear
启动tomcat情况如下:
root@ubuntu:/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就可以使用了。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/32431.html