These instructions use jsvc to daemonize Tomcat. This is the more UNIX method of starting Tomcat at boot time.

Unpack the java server daemon JSVC

The Java Server Daemon JSVC source code is included with the Tomcat 6.0.x binary release.

# Change directories to the Tomcat home directory
cd $CATALINA_HOME/bin

# Unpack the jsvc archive
tar -xvzf commons-daemon-native.tar.gz

# Change directories to the unpacked source directory
cd commons-daemon-1.0.5-native-src/unix

Compile JSVC

Execute the following commands to build the jsvc daemon and copy the daemon executable and startup script to the Tomcat bin directory.

The OS X developer tools must be installed.

# Create the configure file
support/buildconf.sh

# Create the make file (JAVA 5)
./configure

# Create the make file (JAVA 6)
./configure --with-java=/System/Library/Frameworks/JavaVM.framework/

# Build jsvc
make

# Move jsvc into bin
mv jsvc ../..

# Copy the jsvc startup script into bin
cp samples/Tomcat5.sh ../..

# Change directories into bin
cd ../..

# Add execute permissions to Tomcat5.sh
chmod 750 Tomcat5.sh

Edit the daemon startup script Tomcat5.sh

# Edit Tomcat5.sh
nano Tomcat5.sh
# Make sure the following environment variables are set correctly in
# the Tomcat5.sh startup script for your installation. It is recommended that you run
# Tomcat as a user other than root as to restrict Tomcat's access to the host machine.

JAVA_HOME=/Library/Java/Home
CATALINA_HOME=/Library/Tomcat/Home
DAEMON_HOME=$CATALINA_HOME/bin
TOMCAT_USER=<username>
# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=$CATALINA_HOME
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/bundle/Classes/classes.jar:\
$CATALINA_HOME/bin/tomcat-juli.jar:\
$CATALINA_HOME/bin/bootstrap.jar:\
$CATALINA_HOME/bin/commons-daemon.jar
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/jsvc \
.
.
.
stop)
#
# Stop Tomcat
#
$DAEMON_HOME/jsvc \
Start Tomcat as a Daemon

# Execute the startup script to start Tomcat as a daemon
# You must execute the daemon as root as it writes the
# daemon's process id to /var/run.
# If Tomcat is already running, first stop it.
sudo ./Tomcat5.sh start

# Check and see if it is running
ps -ax

# To stop the server ...
sudo ./Tomcat5.sh stop
Starting Tomcat at Boot Time
If you would like Tomcat to start at boot time, create a Launchd property list to load JSVC. Download tomcat-plist.tar.gz and execute the following commands in terminal.

# Change directories to the LaunchDaemons directory
cd /Library/LaunchDaemons

# Unpack the property list
sudo tar -xvzf ~/Downloads/tomcat-plist.tar.gz

# Make sure the property list is owned by root
sudo chown root org.apache.commons.jsvc.plist

# Test
sudo launchctl load /Library/LaunchDaemons/org.apache.commons.jsvc.plist