Installing Tomcat 7.0.x on OS X

Installing Tomcat 7.0.x on OS X

While Tomcat 8 is close to be released (Tomcat 8.0.0-RC5 (alpha) is released already), Tomcat 7 was the first Apache Tomcat release to support the Servlet 3.0, JSP 2.2, and EL 2.2 specifications. Please note that Tomcat 7 requires Java 1.6 or better, which shouldn’t be a problem, if you are running OS X 10.5 or 10.6.

On OS X 10.7, 10.8 (Mnt Lion), and 10.9 (Mavericks) however, Java is not installed anymore, at least not initially. The easiest way to get Java onto your Mac is probably to open the Terminal app and enter java. You will be asked if you want to install it and OS X takes care of the rest – you would end up with Java 6.

Prerequisite: Java

On 10.9 (Mavericks), Apple changed this once again, now sending you to Oracle’s Java SE web page, where you can download the JDK, (currently 7 jdk-7u45-macosx-x64.dmg). While at Oracle, I usually also download the Java SE Development Kit 7 Documentation, allowing me to stay away from their site for many months.
mavericks
The JDK installer package come in an dmg and installs easily on the Mac; and after opening the Terminal app again,

java -version

now shows something like this:

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Whatever you do, when opening Terminal and running java -version, you should see something like this, with a version of at least 1.6.x

sudo is a program for Unix-like operating systems, allowing you to run programs with the security privileges of another user (normally the superuser, or root). Since we are creating directories, outside of your home folder, administrator right are required. I.e., when executing sudo you will be asked to enter your password; and your Mac User account needs to be an ‘Admin’ account.

Installing Tomcat

Here are the easy to follow steps to get it up and running on your Mac

  1. Download a binary distribution of the core module: apache-tomcat-7.0.47.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
  2. Opening/unarchiving the archive will create a folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
    ~/Downloads/apache-tomcat-7.0.47
  3. Open to Terminal app to move the unarchived distribution to /usr/local
    sudo mkdir -p /usr/local
    sudo mv ~/Downloads/apache-tomcat-7.0.47 /usr/local
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat (after removing the old link, you might have from installing a previous version):
    sudo rm -f /Library/Tomcat
    sudo ln -s /usr/local/apache-tomcat-7.0.47 /Library/Tomcat
  5. Change ownership of the /Library/Tomcat folder hierarchy:
    sudo chown -R <your_username> /Library/Tomcat
  6. Make all scripts executable:
    sudo chmod +x /Library/Tomcat/bin/*.sh




Instead of using the start and stop scripts, like so:
Last login: Sun Aug 14 15:20:38 on ttys000
wpbookpro:~ wolf$ /Library/Tomcat/bin/startup.sh
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
wpbookpro:~ wolf$ /Library/Tomcat/bin/shutdown.sh
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
wpbookpro:~ wolf$

you may also want to check out Activata’s Tomcat Controller, a tiny freeware app, providing a UI to quickly start/stop Tomcat. It may not say so, but Tomcat Controller works on OS X 10.8 and 10.9 just fine.


Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page: http://localhost:8080

290 Comments

  1. Thank u very much!

  2. Thx

  3. Thank you ..work like charm ,i’m working first time with mac so i was litlle lost.

  4. Thank you so, much. Very easy to follow.

  5. Thank you so much A LOT of help

  6. Initially was getting a blank page but after executing the step 6 from tomcat directory made the trick.

  7. Congratulation! Very useful your article. It works fine.

  8. Good one, thanks.

  9. Thanks a lot paul…!!
    great article

  10. it works!

  11. Actually, I was trying to install Tomcat on my Linux machine using this guide. I was sure that this guide can be applied on Linux as well because of the syntax but it fails. Can someone guide me, I need help on this. I have found few guides but I haven’t tested yet. Is this one OK?

  12. Great! It works!
    Thanks a lot…

  13. Nice , good, clean tuts!!!

    Your are great !

    Thanks :)

  14. thanks a lot.. :)

  15. Wow best guide ever!
    Thanks a lot i got Tomcat 8 up an running in a few minutes!

  16. Thanks a lot .. :)

  17. This is the best tuto of tomcat configuration. Thank you so much..

  18. Thank you so much! well written.

  19. Great. Though doesn’t cover any set up info.

  20. Thank you so much! Switching over to mac this gave me some much-needed guidance.

  21. Thank you for your well written, clearly laid out tutorial. I’m technically adept but new to using Terminal. I’ve found that some tutorials leave out steps or need tweaks in order to work. Your tutorial worked like a charm. Thank you so very much!

  22. Thanks a lot for such details installation on MAC… great work!

  23. Great tutorial… I just recently switched from Windows to MAC and this helps a lot. :)

  24. Hi
    I had followed the same steps on mac ver 10.9.4 but it did not open Tomcat server for me. I tried to run it from the /bin directory and also restarted the machine . But it is not working. Any suggestion on this would be of help

  25. What should I do if I have installed already Apache on my Mavericks iMac? do I need to deinstall Apache, is it possible that both of them get along with no problems?? thanx i.a.

  26. Now I see they are different things, sorry :S thanx anyway.

  27. Gracias, realmente me ayudó. Thank you so much.

  28. Amazing! All works exactly as you say. Thanks a lot.

  29. Very nice and it’s great to know about the Tomcat Controller tool…

  30. Thank you very much – super clear and concise, worked perfectly.

  31. Thanks dude!

    Hi five from Quebec!

  32. Thanks, great article, just a quick note: probably the best location where to install tomcat (and similar applications) is /opt and not/usr/local.

  33. It worked like a charm but for the fact that i tried with tomcat 8.*.*.
    For this Jre version with a version of at least 1.6.x is not applicable. I would get no error on start up attempt but on shut down. Of course the server wasn’t responding either when i decided to upgrade to latest JDK and JRE. I now have 1.8* and it’s working like a charm.

    Thanks Wolf for such easy steps. Couldn’t all this be packaged as one script? A job for DevOps i guess.

  34. Thank you so much! I had been looking at documentation on Apache’s own site as well as on Stackoverflow and neither place was able to provide clear, easy-to-read, step-by-step instructions on how to install and run Tomcat. This article makes it easy; you’re awesome!

  35. Thank you very much !!!!

  36. So, if I already have the php apache server running on my machine, all I’d have to to to switch between them is stop the php server and start the tomcat (and same backwards)?

  37. Thank you for such a clear and concise tutorial.

  38. Great tut: clear, concise, precise! Thanks a lot.

  39. Muchas gracias me sirvió de mucho….

Trackbacks/Pingbacks

  1. Bioinformatics Program - Division of Biomedical Statistics and Informatics - Mayo Clinic Research - […] We want Tomcat 7.  Here are some instructions on a Mac: http://wolfpaulus.com/jounal/mac/tomcat7/ […]
  2. JSF Installation help for mac | Allah is the one and only - […] http://wolfpaulus.com/jounal/mac/tomcat7/ […]
  3. Install Tomcat on OSX | Felix' Blog - […] See http://wolfpaulus.com/jounal/mac/tomcat7/ […]
  4. Wolf Paulus: Installing Tomcat 7.0.x on OS X - […] Turns out that installing Tomcat on a Mac is actually pretty easy. I ended up following Wolf Paulus’ tutorial here. …

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>