How to Install and run Tomcat on MacOS

Here’s how I install and run Tomcat on Mac OSX.  It never seem to go smoothly, so I thought I’d write down how to do it.

1) We will build it form source, so you need a C compiler.  Download and install the Apple Developer tools from developer.apple.com/mac.  You will need to register (free) if you don’t have an account, log in, download, and install Xcode.  This will install Xcode, gcc, and the Mac SDK.

2) Download and install MacPorts.  MacPorts is the open-source way to install and run open-source software on Mac OSX.

3) You can check that MacPorts installed correctly.  Once installed, open a shell window (/Applications/Utilities/Terminal.app).  You should be able to type ‘port version’ or ‘port help’ and get a response.

4) Install Tomcat by typing ‘sudo port install tomcat6’.  Replace ‘tomcat6’ with ‘tomcat5’, if that is the version you are after.  To see all versions of Tomcat available for install from MacPort, type ‘port list | grep tomcat’.

5) Once installed, you need to make a few tweeks to get it to run.  The first is to set up the tomcat-users.xml file in tomcat6/conf.  Edit the contents to look like:

<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

<role rolename="tomcat"/>

<role rolename="manager"/>

<role rolename="admin"/>

<user username="tomcat" password="password" roles="tomcat,admin,manager"/>

<user username="mike" password="password" roles="tomcat,admin,manager"/> </tomcat-users>

Username “mike” can be any username of your choosing, it doesn’t need to be me ;->

6) The second tweek is to “fix” the file permissions on a number of files.  In your shell window, cd to the tomcat6/bin directory and set all the .sh files so they are readable and executable:

sudo chmod 755 *.sh

7) The final tweek is to set the tomcat6 log files so they are writeable by tomcat.  cd to the logs directory and change file permissions:
sudo chmod 777 catalina.*

That should be it.  Start Tomcat be cd’ing to the bin directory and running:
sudo ./startup.sh

You can verify Tomcat is up and running by browsing to http://localhost:8080 in your browser.

Leave a comment

  1. Pingback: Full guide for installing tomcat on OS X

  2. Pingback: Full guide for installing tomcat on OS X | Joshua Pyle

  3. Pingback: Mac OS | 3Gepard Blog

  4. Pingback: How-to: How do I start Apache Tomcat at boot on Mac OS X? #computers #dev #it | IT Info

  5. Pingback: Answer: How do I start Apache Tomcat at boot on Mac OS X? #computers #answer #programming | SevenNet

  6. Pingback: Fixed: How do I start Apache Tomcat at boot on Mac OS X? #fix #programming #development | Good Answer