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

250 Comments

  1. Great instructions. Thanks!

  2. Excellent !!! thanks

  3. Excellent, succinct instructions! Thanks for taking the time to put this together.

  4. Great instructions! Thank you

  5. Great instructions! Thanks a lot!

  6. I had been having a tough time getting Tomcat to work for some Spring training last week; I have many old versions of Tomcat around from years ago. Found your instructions to be very clear and helpful (after floundering around with other advice for a few days). I did find it necessary to modify step 6 to get it working (on Mavericks). Not sure if I did something wrong or just an oversight in your instructions. I installed version 7.0.50. Inserting the folder name in the path got it working for me.

    Cheers, Don

    6. Make all scripts executable:
    sudo chmod +x /Library/Tomcat/apache-tomcat-7.0.47/bin/*.sh

  7. Fantastic Tutorial. Thanks

  8. Thanks for this support ! Tomcat installed in 5 minutes ! cO_OL !! cheers from brussels.

  9. Thanks for the great article. It helped me bring up my tomcat in minutes.

  10. It worked perfectly.
    Thanks a lot!!!
    I’ve tried several tutorials but none of them worked!

  11. Great Article. Was able to install tomcat very easily. Many Thanks for your help

  12. Great tutorial, Thanks

  13. Thats great nice one

  14. Great set of instructions. Up and running in no time. On 10.8.5 wasn’t able to install the Tomcat Controller so set up aliases in .bash_profile instead.

    alias tomstart=’/Library/Tomcat/bin/startup.sh’;
    alias tomstop=’/Library/Tomcat/bin/shutdown.sh’;

  15. Wonderful post. After weeks of trying one solution after another, i landed on your post and did the configurations under 5 mins. Your a time saver.
    Thanks Dan

  16. Worked perfectly, thanks!

  17. I wanted to extend my thanks for making this process as simple as possible. Easy install – everything worked, you are a life saver! Thank You.

  18. Perfect!
    thank you

  19. thank you for the instructions they are very clear and help me to install rapidly tomcat

  20. Thank you for the instructions. Worked perfectly.

  21. Thank you very much! I was ready to break the computer.

  22. excellent post! very quick.

  23. Wonderful article. After weeks of browsing and research, and found this post.I was able to set up apache easily after reading this.Expecting many such articles from you.
    Thanks once again for the tutorial and guidance.

  24. Thanks for the article – best instructions I’ve come across. Finally able to get Tomcat running on Java 7!

  25. Like

    +1

  26. Great! Thank you!

  27. Great tutorial, thanks!

  28. Excellent post. Cake walk!!!

  29. Nice tutorial. One thing, if port 8080 is already blocked, tomcat do not show any error or log message in the console. In my case, jenkins was running in localhost, so Tomcat says its running, but http://localhost:8080 still shows the jenkins home page. After I close jenkins, its ok.
    You can mention this issue if port 8080 is blocked what to do. How to print log message when running tomcat?

  30. Thank’s for all :D. I can run my tomcat :D

  31. Excellent!! Really it save my time.. Thanks a lot !!

  32. Thanks for clear explanations. It took me no time to install .

  33. Thanks Wolf ! That was quick

  34. Is there any way to run multiple tomcat using this? Currently using this steps and Tomcat Controller, i can handle only 1 tomcat. I want to handle atleast 3 tomcat.

  35. Thank you very much for this well written, easy to follow guide. You rock!
    Cheers,
    Vivek

  36. Hi, thanks for the instruction.
    Under which account do run Tomcat?

  37. thanks!

  38. Very useful article! Thanks

  39. Thank you so much!

  40. Thank you so much for this article it helped me a lot

  41. Need help

    patompong:~ fook$ /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/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home
    Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
    touch: /Library/Tomcat/logs/catalina.out: No such file or directory
    /Library/Tomcat/bin/catalina.sh: line 385: /Library/Tomcat/logs/catalina.out: No such file or directory
    patompong:~ fook$

  42. Great job on this. worked like a charm!

  43. Thanks A LOT!! That’s exactly what I was looking for.

  44. Perfect! Thanks a lot.

  45. Thankyou from myself and every 2014 computing grad @ Surrey!

  46. This worked perfectly. Thanks for the write-up!

  47. Work like champ! Thanks a lot!

  48. The install worked great except that the roles do not work.
    I am unable to configure any users in the tomcat-users.xml file. The roles that are supposed to exist in the web.xml file are not there.

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>