fedora下安裝tomcat問題
我在fedora下安裝tomcat遇到如下問題:
運行startup.sh后提示
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
已經安裝了JDK6.0,並且環境變數已經設置了,各種java工具都可以運行,環境變數是在~/.bashrc中設定的,要安裝tomcat6
.bashrc中的配置為:
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export PATH
請問下,我的配置是不是正確的,或者是tomcat還不支持JDK6.0啊
[ 本帖最後由 bhdgx 於 2008-1-18 00:04 編輯 ]
《解決方案》
配置到tomcat的啟動文件裡面。
《解決方案》
如果你的tomcat是作為伺服器啟動的話,
配置到tomcat.conf裡面。
我以前配置的/etc/tomcat.conf,大概兩年前吧。
# tomcat5 service configuration file
# $Id: tomcat.conf 12 2006-03-22 13:00:43Z root $
# you could also override JAVA_HOME here
# Where your java installation lives
JAVA_HOME="/opt/java"
TOMCAT_HOME="/opt/tomcat"
# You can pass some parameters to java
# here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
# Where your tomcat installation lives
# That change from previous RPM where TOMCAT_HOME
# used to be /var/tomcat.
# Now /var/tomcat will be the base for webapps only
CATALINA_HOME="$TOMCAT_HOME"
CATALINA_TMPDIR="$TOMCAT_HOME"/temp
JASPER_HOME="$TOMCAT_HOME"
JAVA_ENDORSED_DIRS="$TOMCAT_HOME"/common/endorsed
# What user should run tomcat
TOMCAT_USER="root"
# You can change your tomcat locale here
#LANG=en_US
# Time to wait in seconds, before killing process
SHUTDOWN_WAIT=30
# Set the TOMCAT_PID location
CATALINA_PID="/var/run/tomcat.pid"
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
# Just do not forget to export them :)
/etc/init.d/tomcat
#!/bin/sh
#$Id: tomcat.init 13 2006-03-22 13:02:03Z root $
#
# Startup script for Tomcat 5.5, the Apache Servlet Engine
#
# chkconfig: - 80 20
# description: Tomcat 5.0 is the Apache Servlet Engine RI for Servlet 2.4/JSP 2.0
# processname: tomcat
# pidfile: /var/run/tomcat.pid
# config: /etc/tomcat.conf
#
# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
# Get Tomcat config
TOMCAT_CFG="/etc/tomcat.conf"
[ -r "${TOMCAT_CFG}" ] && . "${TOMCAT_CFG}"
export JAVA_HOME=$JAVA_HOME
# Path to the tomcat launch script (direct don't use wrapper)
START_TOMCAT=${TOMCAT_HOME}/bin/startup.sh
STOP_TOMCAT=${TOMCAT_HOME}/bin/shutdown.sh
# Tomcat name
TOMCAT_PROG=tomcat
RETVAL=0
# See how we were called.
start() {
echo -n "Starting ${TOMCAT_PROG}: "
if [ -f /var/lock/subsys/tomcat ] ; then
if [ -f ${CATALINA_PID} ]; then
read kpid < ${CATALINA_PID}
if checkpid ${kpid} 2>&1; then
echo "process allready running"
return -1
else
echo "lock file found but no process running for pid ${kpid}, continuing"
fi
fi
fi
if [ -x /etc/rc.d/init.d/functions ]; then
daemon --user ${TOMCAT_USER} ${START_TOMCAT}
else
su - ${TOMCAT_USER} -c ${START_TOMCAT}
fi
RETVAL=$?
echo
[ ${RETVAL} = 0 ] && touch /var/lock/subsys/tomcat
return ${RETVAL}
}
stop() {
echo -n "Stopping ${TOMCAT_PROG}: "
if [ -f /var/lock/subsys/tomcat ] ; then
if [ -x /etc/rc.d/init.d/functions ]; then
daemon --user ${TOMCAT_USER} ${STOP_TOMCAT}
else
su - ${TOMCAT_USER} -c ${STOP_TOMCAT}
fi
RETVAL=$?
if [ ${RETVAL} = 0 ]; then
count=0;
if [ -f ${CATALINA_PID} ]; then
read kpid < ${CATALINA_PID}
let kwait=${SHUTDOWN_WAIT}
until [ `ps --pid ${kpid} | grep -c ${kpid}` = '0' ] || [ ${count} -gt ${kwait} ]
do
echo "waiting for processes to exit";
sleep 1
let count=${count}+1;
done
if [ ${count} -gt ${kwait} ]; then
echo "killing processes which didn't stop after ${SHUTDOWN_WAIT} seconds"
kill -9 ${kpid}
fi
fi
rm -f /var/lock/subsys/tomcat ${CATALINA_PID}
fi
else echo "Lock file(subsys) not found ..."
exit 1
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
if [ -f ${CATALINA_PID} ]&&checkpid `cat ${CATALINA_PID}`;
then
echo "tomcat (pid `cat ${CATALINA_PID}`) is running..."
else
echo "tomcat is not running..."
exit 1
fi
;;
restart)
stop
sleep 2
start
;;
condrestart)
if [ -f ${CATALINA_PID} ] ;
then
stop
start
fi
;;
*)
echo "Usage: ${TOMCAT_PROG} {start|stop|restart|condrestart}"
exit 1
esac
exit ${RETVAL}
腳本稍微修改一下可以用於redhat,fedora應該也沒有問題。
《解決方案》
多謝樓上的,問題解決了。
我是在.bashrc文件中設置了CATALINA_HOME就可以了