Tomcat on Mac OS X Tiger

Download the ‘Core’ .tar.gz version of Tomcat (as of this writing 5.5.15) from http://tomcat.apache.org/download-55.cgi. Extract and move the folder:

sudo mv ~/Desktop/apache-tomcat-5.5.15 /usr/local/

That’s all you need to do to actually install Tomcat–nice and simple. Now to create some start and stop scripts…

cd /usr/local/bin
sudo nano start_tomcat

Enter the following and save:

#!/bin/sh
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.15
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
$CATALINA_HOME/bin/startup.sh

Now a stop script:

sudo nano stop_tomcat

Enter the following:

#!/bin/sh
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.15
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
$CATALINA_HOME/bin/shutdown.sh

Voila! Now to start Tomcat, use /usr/local/bin/start_tomcat and to stop it use /usr/local/bin/stop_tomcat.

If you have /usr/local/bin included in your PATH environment variable, then you can start and stop Tomcat using start_tomcat and stop_tomcat respectively straight from the Terminal.

When Tomcat is started, you can see the installation by going to http://localhost:8080/. In order to manage Tomcat, you’ll need to modify the tomcat-users.xml file.

cd /usr/local/apache-tomcat-5.5.15/conf
sudo nano tomcat-users.xml

Inside this file, modify it so it includes the following tags:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="davidwinter" password="123" roles="admin,manager"/>
</tomcat-users>

Where davidwinter is the username you want to use, and 123 being the password you desire.

You can then manage your Tomcat applications using this link; http://localhost:8080/manager/html.

2006-02-20 [, , , ]

Comments

  1. As I am forever repeating the start/stop procedure from the terminal, I made a simple tool that you may find of use, you can download it from here: http://www.activata.co.uk/

    John Wylie (2007-01-09 @ 16:45)
  2. Thank you very much for your post! you made to install Tomcat in Mac very easy ^^

    Regards from Spain

    Marta (2008-10-06 @ 21:32)
  3. You can also add a LaunchDaemon in /Library/LaunchDaemons/ that will automatically start Tomcat on boot. I have instructions for this and how to run it behing Apache 2.2.x using mod_proxy on my blog at http://www.latko.org/2009/02/12/installing-tomcat-60x-behind-apache-22x/

    Chris Latko (2009-02-12 @ 20:52)
  4. You need to have the proper permissions for executing the start up scripts, elsewhere i found this:

    chmod ugo+x $TOMCAT_HOME/bin/*.sh

    Before that i got this error: The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program

    Kees van Daalen (2009-03-06 @ 20:53)
  5. There’s similar tutorial for Tomcat 6 at mactekkie.com: http://www.mactekkie.com/tutorials/installingTomcat.php

    I think it’s funny that it’s about Tomcat (JAVA) but the tutorial is written in PHP.

    :)

    Paul Hewson (2009-04-30 @ 03:21)

Powered by WP Hashcash