Tuesday, February 3, 2009

Setting up Tomcat on Mac OS X

from http://wiki.apache.org/tomcat/TomcatOnMacOS - many thanks!

Found this link after a long search for trying to setup Apache Tomcat on my Mac OS X:

Many thanks again to Basil Bourque and Michael Valentiner - for the 2008 update,

Steps:

1. Upgrade to Mac OS X 10.4.6

- I do not know if 10.4.6 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/]
- Drag and drop the entire Tomcat folder onto the BatChmod icon.
- 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 additional steps.

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
This would not be necessary if you are already using another server for example Apache (web server) which uses port 80 by default.

8. Test Tomcat

- Launch a web browser such as Safari.
- Goto: http://127.0.0.1/ [note: no port 8080 at the end]
- 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.

Updated for 2008 (by Michael Valentiner)

Verified running Tomcat 6.0.14 on Mac OS X 10.5.1.
Did not need to set up JAVA_HOME and did need to fix Unix file permissions.
The System Preferences > Sharing > Firewall has moved to System Preferences > Security > Firewall. Able to enable logging, but haven't figured out how to block UDP.


You might want to look at:
  • http://wiki.apache.org/tomcat/TomcatOnMacOS
  • http://tomcat.apache.org/
  • http://en.wikipedia.org/wiki/Apache_Tomcat
  • No comments: