Skip Navigation

Installing Apache Tomcat on Mac OS X

By Robert Crews

This document describes installing Apache Tomcat on Mac OS X. When complete, Tomcat will start up along with the operating system, will be integrated with the Apache web server built into the operating system, and will be fully controllable with the standard Mac OS X SystemStarter utility.

Apache Tomcat, the reference implementation for Java's servlet technology, was written by James Duncan Davidson—creator of Ant, author of Ant: The Definitive Guide, Running Mac OS X Panther, Running Mac OS X Tiger, Mac OS X Panther Hacks, Cocoa in a Nutshell, Learning Cocoa with Objective-C, 2nd Edition, and major contributor to Ruby on Rails—while he was working as a software architect for Sun Microsystems from 1997 to 2001. He was instrumental in getting Sun to release the software as open source and donate the source code to the Apache Software foundation.

For Tomcat 4, Craig McClanahan—creator of Apache Struts and member of the expert group responsible for the 2.2 and 2.3 Java servlet specifications and the 1.1 and 1.2 JSP specifications—significantly enhanced Tomcat's servlet implementation, calling it "Catalina." Tomcat 4 also included a major upgrade to the JSP processor called "Jasper." (Think of a tool that works on a JSP—"jasp"—as a jasper… or not.)

In addition to architectural and functional improvements, major Tomcat releases coincide with Tomcat's implementation of updates to the Java servlet and JSP specifications. Tomcat is popular because is it easy to install, easy to manage, and easy to integrate with the Apache web server. It has good standards compliance, many useful features, and is relatively fast.

Creating the Apache Tomcat User and Group

To create the Apache Tomcat user and group:

  1. Run the following from the Mac OS X command line:

    $ sudo dscl . -create /groups/tomcat ;\
    sudo dscl . -create /groups/tomcat Password "*" ;\
    sudo dscl . -create /groups/tomcat PrimaryGroupID 498 ;\
    sudo dscl . -create /groups/tomcat RealName "Apache Tomcat Users" ;\
    sudo dscl . -create /users/tomcat ;\
    sudo dscl . -create /users/tomcat Password "*" ;\
    sudo dscl . -create /users/tomcat UniqueID 498 ;\
    sudo dscl . -create /users/tomcat PrimaryGroupID 498 ;\
    sudo dscl . -create /users/tomcat RealName "Apache Tomcat Server" ;\
    sudo dscl . -create /users/tomcat NFSHomeDirectory /var/empty ;\
    sudo dscl . -create /users/tomcat UserShell /usr/bin/false

    See the dscl man page for more information.

  2. Hide the tomcat user (and all other users with a UniqueID less than 500) from the Mac OS X GUI:

    $ sudo defaults write /Library/Preferences/ Hide500Users -bool true

Building and Installing Apache Tomcat


To install Apache Tomcat:

  1. Get Apache Tomcat source and unpack it into /usr/local.

    $ pushd .;
    cd /usr/local ;\
    sudo curl -O \ ;\
    sudo tar xvfz apache-tomcat-6.0.18.tar.gz ;\
    sudo chown tomcat:tomcat apache-tomcat-6.0.18 ;\
    sudo ln -s apache-tomcat-6.0.18 apache-tomcat ;\
  2. Create a file containing the following data at /Library/LaunchDaemons/org.apache.tomcat.plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    <plist version="1.0">

    The Disabled key—set to "true" above—controls whether or not Apache Tomcat will automatically start when your computer boots. Disabled true means it will not start automatically. The launchctl command provides a -w command flag to set or unset the Disabled flag without requiring you to edit the file in a text or XML editor.

  3. Start Apache Tomcat:

    $ sudo launchctl load -w /Library/LaunchDaemons/org.apache.tomcat.plist

    Note the presence of the -w flag that removes the org.apache.tomcat.plist Disabled flag, configuring Apache Tomcat to automatically launch when your computer boots.