Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

With considerable help from Joachim, Tracy, Tom, Samuel and Jonel from the Apple Web and Java Developer mailing lists.

Updated for 2006

Basil Bourque says:

Today (2006-04-05) I disovered a somewhat different recipe to running Tomcat 5.5.16 on Mac OS X 10.4.6.

  • Today's Tomcat (v5.5) wants to run on Java 5, but Apple's command line defaults to Java 4 (1.4.2). Surprisingly, Tomcat's script works around this.
  • I did not need to set any environment variables (JAVA_HOME).
  • But I did need to fix vital file permissions in the downloaded Tomcat folder.

(1) Upgrade to Mac OS X 10.4.6

  • I do not know if this is required, but it sure made an easy Tomcat install.
  • Apply all of Apple's Software Updates, especially the Java 5 update.

(2) Download apache-tomcat-5.5.16

  • Unzip.
  • Move it to your home folder.

(3) Fix the Unix file permissions

  • Download the freeware BatChmod, a GUI wrapper around the Unix "chmod" command.
    http://macchampion.com/arbysoft/
  • Drap and drop the entire Tomcat folder onto BatChmod.
  • Check *all* the checkboxes.
  • Click "Apply" and give your Administrator password.

(4) Start Tomcat

  • Launch /Applications/Utilities/Terminal.
  • Navigate to the Tomcat folder (apache-tomcat-5.5.16):
    cd ~/apache-tomcat-5.5.16
  • Run the startup script:
    ./bin/startup.sh
  • You should see something like this:
    Using CATALINA_BASE: /Users/basilbourque/apache-tomcat-5.5.16 Using CATALINA_HOME: /Users/basilbourque/apache-tomcat-5.5.16 Using CATALINA_TMPDIR: /Users/basilbourque/apache-tomcat-5.5.16/temp Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
  • Notice that somehow the startup script(s) have used Java 5 on Mac OS X even though it is not the default Java runtime at the command line. I hope to parse that script later to discover how they did this.

(5) Test Tomcat

  • Launch a web browser such as Safari
  • Goto http://127.0.0.1:8080/
  • You should see the cute Tomcat logo on the welcome page.

You are technically done at this point. But as a good pratice, I also did the following.

(6) Start the Firewall

  • System Preferences > Sharing > Firewall > Start
  • Also, click the Advanced button on that panel, to (a) block UDP, and (b) start logging. It is fascinating to see how quickly a computer directly on the Internet starts to get queried/tested/attacked. Open /Applications/Utilities/Console to see the log.

(7) Enable Port-Forwarding

  • Add a rule to do port-forwarding from port 80 to Tomcat's default port 8080. Type this in the Terminal:
    sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in Or use this nifty program, another GUI wrapper around the ipfw command line, Simple Port Forwarder: http://www.4dresources.com/files/

The Sharing SysPref will get cranky when you add an ipfw rule behind its back; it disables its user interface. To use the Sharing SysPref again you'll have to clear that rule, the one we added and numbered 100. To delete a rule, either read the ipfw man page, or use Simple Port Forwarder again. Quit the System Preferences program, and re-launch it to re-enable its Firewall panel.

(8) Test Tomcat

  • Launch a web browser such as Safari
  • Goto http://127.0.0.1/
    Notice that we left off the port number this time, so the web browser defaults to port 80. Or you can explicitly say port 80: http://127.0.0.1:80/
  • You should see the cute Tomcat logo on the welcome page.
  • To be sure it is working, and not cached by the browser:
    • Try another browser.
    • Click the Reload button in the toolbar of the browser.
    • Choose the Reload command, such as View > Reload Page in Safari.

(9) Walk the dog

  • Enjoy an all-too-rare moment of computing satisfaction.

As best as I can recall, that is all I had to do today. I hope I am not steering you wrong. I did assume at first that Java 5 would not be used be default, so I wasted time messing with the path ($PATH) and setting the environment variable JAVA_HOME. But I undid those, as they failed. I then tried the simple steps above, and it worked.

I hope to refresh my own web site with this info: http://www.BasilBourque.org/

--Basil Bourque