I’ve been fiddling around getting Tomcat running on OSX 10.6, which is trivial if you do things right, but here are som potential snags. This might be documented all over the place, but I’m making a note here for myself. I think I’ve installed Tomcat on about 50 machines over the years, so I enjoyed some nice flashbacks as I sorted this out.
First: download Tomcat. derp.
Second: check the md5 hash using ‘
$ md5 <zipfile> | grep -v <expected hash>‘. Or, don’t check it. Probably not a ton of people hacking a keystroke logger into Tomcat. I think checking the hash is fun.
Third: extract the archive. derp de der! Folks recommend
/Libraray/Tomcat/Home/ as a final resting place. If you don’t have execute permission on the extracted directory, make it so. I like
'chmod a+x' instead of
'777', but whatever works. If you don’t do this, you’ll get complaints about permissions, or that ‘catalina.sh’ is missing, or even worse ‘BASEDIR environment variable is not defined correctly’.
Fourth: run Tomcat. der derp der derr!!! Here’s where things can go a little crazy. You don’t have to set
$CATALINA_HOME as a environment variable. You don’t even have to set
$JAVA_HOME, which should be
/Library/Java/Home. There is a
shutdown.sh script in the
/bin directory of the Tomcat install (ie
/Library/Tomcat/Home/bin). I prefer to make my own wrapper for these scripts, named
tomcatStop, and put them in my
~/bin folder, which is in my path. That way I don’t have to type the whole path to the Tomcat scripts, and it’s a little more explicit as to what I’m starting up or shutting down. Alternately, you could just call Tomcat’s
catalina.sh script, with either start or stop as an argument.
Be aware that calling an executable script directly, eg
'$scriptname' is different than calling it using the source operator in bash, eg
'$. scriptname‘. Using the source or ‘.’ operator causes the shell to run the script directly, instead of using a subshell. This will cause an error, because the
$0 argument will become ‘
-bash‘, instead of the path of the script.
Fun Fact: you might have (depending on your download method) the HFS+ bit set which ‘quarantines’ files from the internet. You will see an ‘@’ in the extended list attribues, ‘
-rw-r--r--@‘ <— like that. That means you have the quarantine plague. It won’t keep the files from starting up, but you might get a warning message if you try to open the files with a visual editor. The remedy? Run ‘xattr -d -r com.apple.quarantine *’ to clean this up.