LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how can i install tomcat? (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-install-tomcat-394121/)

hadiseh 12-18-2005 06:11 AM

how can i install tomcat?
 
hi
when i install tomcat ,it seems every thing is ok.but when i tried:

jakarta-tomcat-5.5.9/bin/startup.sh

it gives me this error:

The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program

how can i solve this problem?plz help me

megaspaz 12-18-2005 10:44 AM

you need to set the CATALINA_HOME and JAVA_HOME environment variables as well as update your CLASSPATH environment variable.

You can do this in /etc/profile. If you put it in here, you'll then need to 'source /etc/profile' before you start up tomcat.

Mine:
Code:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
          if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
          else
              PATH=$1:$PATH
          fi
        fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

CVSROOT=/usr/local/cvsroot
pathmunge $CVSROOT after
export CVSROOT

export EDITOR=vim

JAVA_HOME=/usr/java/j2sdk1.4.2_10
pathmunge $JAVA_HOME/bin after
export JAVA_HOME

KOMODO_HOME=/usr/local/Komodo
pathmunge $KOMODO_HOME after
export KOMODO_HOME

ANT_HOME=/usr/local/apache-ant-1.6.2
pathmunge $ANT_HOME/bin after
export ANT_HOME

CATALINA_HOME=/usr/local/tomcat
export CATALINA_HOME

AXIS_HOME=/usr/local/axis
pathmunge $AXIS_HOME/bin after

AXIS_LIB=$AXIS_HOME/lib
pathmunge $AXIS_LIB after

AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery-0.2.jar:$AXIS_LIB/commons-logging-1.0.4.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/wsdl4j-1.5.1.jar:$AXIS_LIB/axis-ant.jar


CLASSPATH=/usr/local/tomcat/bin:/usr/java/j2sdk1.4.2_10/lib:/usr/local/tomcat/common/lib:/usr/local/tomcat:/usr/java/j2sdk1.4.2_10/lib/mysql-connector-java-3.1.12-bin.jar:$AXISCLASSPATH:/usr/local/xerces/resolver.jar:/usr/local/xerces/xercesImpl.jar:/usr/local/xerces/xercesSamples.jar:/usr/local/xerces/xml-apis.jar
export CLASSPATH

export AXIS_HOME
export AXIS_LIB
export AXISCLASSPATH

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
            . $i
    fi
done

unset i


hadiseh 12-19-2005 01:38 AM

hi
thx for reply.i export my CATALINA_HOME and JAVA HOME and it runs well.but after some minutes when i tried again it doesn't work.and now some times it workes and some times it doesn't.do u know what happen?

megaspaz 12-19-2005 02:53 AM

well, if you've export your variables as commands in a shell term (like konsole), those variables are only valid during that shell's session. this means when you exit the shell, the environment variables are lost. If you've set the variables in /etc/profile, the most reliable way to make sure the variables are set everytime you login in or use the shell term would be to reboot the machine, but logging in and out of your session should work, although, I've had logging in and out not work for me before.

My guess is that it doesn't work the next time because you've export those environment variables in a shell term, close the shell term, and then try to start it up again in a new shell term.

But I don't really know, as I'm not using version 5.X of tomcat; I'm using 4.1.31. It could be something like version 5.X is buggy... I couldn't really tell you.

Another thing, update your CLASSPATH environment variable also.

hadiseh 12-19-2005 05:57 AM

thx a lot.u help me so much.but i'm new in linux and cann't understand how can i do this?can u explain more?

megaspaz 12-19-2005 11:36 AM

Well let me ask you, how do you boot up into linux? Do you boot straight into graphical mode (init 5)?

Let's pretend you do. Here's the scenario.

You log into your user account. You open up a shell terminal. You su into root so you can start tomcat. You need to set the environment variables, so you do. You start up tomcat. You exit out of root. Now you want to restart tomcat, so you su back into root. Now here is where you'd have problems. Those environment variables you set in your previous session are no longer set. You need to make those environment variables permanent. So look at the example /etc/profile I posted and copy the lines you need in regards to classpath, catalina_home, and java_home.

For the classpath, you'd probably only need:
CLASSPATH=/usr/local/tomcat/bin:/usr/java/j2sdk1.4.2_10/lib

After editing your /etc/profile, log out of your user session and log back in. Your environment variables should be set for you and when you su as root in the shell term.

You can see by typing in the command:

echo $CLASSPATH
echo $JAVA_HOME
echo $CATALINA_HOME

if the outputs come up blank, and you're sure you've set up your /etc/profile correctly, then just reboot the machine. Else, you should be golden.

hadiseh 12-20-2005 01:15 AM

thx dear megaspaz.u solve my problem.thx a lot


All times are GMT -5. The time now is 08:37 AM.