Kenno’s OpenNote

Tomcat 6 on Debian Lenny

Posted in Debian, Java, Open Source, Unix/Linux by kenno on August 14, 2007

I need to install Tomcat 6 for a school assignment. I thought the installation process was easy as counting 123, but it turned out to be a few hours long of head scratching. Well, the first start is to setup a few environment variables as required by Tomcat:

CATALINA_BASE=/home/kenno/bin/apache-tomcat-6.0.13
CATALINA_HOME=/home/kenno/bin/apache-tomcat-6.0.13
export CATALINA_HOME;
export CATALINA_BASE# JAVA_HOME and Path to java, javac
JAVA_HOME=/usr/lib/j2sdk1.6-sun/bin
export JAVA_HOME;
export PATH=${JAVA_HOME}/bin:${PATH}:.

It can be stored in a setEnv.sh file, and run with source setEnv.sh to load those variables.

Then when I tried to run Tomcat with the following command, there was some error with the BASEDIR:

kenno@kampongcham:~$ $CATALINA_HOME/bin/startup.sh
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program

I wasted a few hours trying to search for solutions on Google, and as when I was about to temporarily give up for dinner, I found an unexpected answer from one of the blogs.

“I need to set all the shell scripts in $CATALINA_HOME/bin to be executable”

So let’s fix it:

kenno@kampongcham:~$ cd $CATALINA_HOME/bin
kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ chmod +x *.sh

Finally, it’s done. We can now run tomcat without any errors:

kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ ./startup.sh
Using CATALINA_BASE:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_HOME:   /home/kenno/bin/apache-tomcat-6.0.13
Using CATALINA_TMPDIR: /home/kenno/bin/apache-tomcat-6.0.13/temp
Using JRE_HOME:       /usr/lib/j2sdk1.6-sun/bin

That’s it folks. When you setup Tomcat on your machine, make sure you specify the correct path to all the variables mentioned above.

Thanks to Michael for the solution: Tomcat 6 on OSX

13 Responses

Subscribe to comments with RSS.

  1. Johnny Utah said, on December 4, 2007 at 10:28 pm

    Thank you!!

  2. kenno said, on January 26, 2008 at 3:59 pm

    Glad this post is helpful. :)

  3. danny said, on March 11, 2008 at 8:47 pm

    searched around google and found this post. THANKS! now i can eat lunch.

  4. kenno said, on April 2, 2008 at 2:01 pm

    Enjoy your lunch. The last time I had this problem, I didn’t have dinner until I get it fixed too.

  5. Antonio said, on October 27, 2008 at 11:22 am

    Fine post, thank you. But as for me, I prefer not to hardcode . into PATH.

  6. Melodie said, on December 1, 2008 at 8:59 pm

    Well, I have tried all of the above and am still getting the error

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

    I am using Tomcat 5.5.27 on Linux Debian.

    I am also using su to the user that has rights.

    Thanks for any help as I am stumped!

    Melodie

  7. Thushara said, on December 15, 2008 at 9:24 am

    The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program. it’s a permission issue. run bellow command

    cd $CATALINA_HOME/bin
    chmod u+x *

  8. jastazv said, on February 13, 2009 at 10:32 pm

    That was good.

    Thank you. I was looking for something like that.

  9. tychoish said, on July 27, 2009 at 6:27 pm

    Tomcat 6 is now in squeeze, and is included with ubuntu since 9.04, which means, you can install via packages in a way that’s coherent with the existing system. I’m not sure about the state of the dependencies but you might be able to install the squeeze packages on lenny without much fussing.

    • Kenno said, on July 27, 2009 at 11:47 pm

      Thanks for the update @tychoish. I haven’t touched Tomcat since 2007, a few months after this post was written.

      • tycho said, on July 28, 2009 at 12:07 pm

        and fair enough, really, I can’t see much merit to it, unless you have something that already needs it… but when you need it, it’s a good thing indeed. but you have some google juice here, and now that lenny is stable, I just wanted to clarify…

  10. azhar ali buttar said, on August 18, 2009 at 2:22 pm

    Hey guys,

    If you guys are getting base dir error then please check the post under given on IT Operationz. Hope it will help you to solve your problem.

    http://www.itoperationz.com/2009/06/how-to-install-and-configure-apache-tomcat-6-on-debian-5/

    A startup script for tomcat is also included in that post.


Leave a Reply