Installing Tomcat 7.0.x on Mac OSX

ImageImage

Tomcat 7 is 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, but that shouldn’t be a problem, if you are running OS X 10.5 or 10.6.

On OS X 10.7 (Lion) however, Java is initially not installed anymore. You can find the installer on Apple’s support side here or follow this installation guide, provided by Adobe. Whatever you do, when opening Terminal and running java -version, you should see something like this.

java version “1.6.0_29”
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

Here are the effortless steps which should be followed to get your Tomcat Server running on your Mac.

Step 1: Download a binary distribution of the core module: apache-tomcat-7.0.26.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.

Step 2: Opening or Unarchiving the tar.gz file will create a folder something like this in your Downloads folder ~/Downloads/apache-tomcat-7.0.26

Step 3: Move the unarchived distribution to /usr/local

             sudo mkdir /usr/local

             sudo mv ~/Downloads/apache-tomcat-7.0.26  /usr/local

Step 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:

sudo ln -s /usr/local/apache-tomcat-7.0.26  /Library/Tomcat

Step 5: Change ownership of the /Library/Tomcat folder hierarchy:

sudo chown -R <your username>  /Library/Tomcat

Step 6: Make all scripts executable:

sudo chmod +x /Library/Tomcat/apache-tomcat-7.0.26/bin/*.sh

This command executes the startup.sh which starts the tomcat server.

Step 7: Now open your Web Browser and goto http://localhost:8080

You should see the following window.

Image

Instead of using the start and stop scripts, like so:

Last login: Sun Mar18 09:00:18 on ttys000

Zerocools-Macbook:~ zerocool$ /Library/Tomcat/apache-tomcat-7.0.26/bin/startup.sh
Using CATALINA_BASE: /Library/Tomcat/apache-tomcat-7.0.26
Using CATALINA_HOME: /Library/Tomcat/apache-tomcat-7.0.26
Using CATALINA_TMPDIR: /Library/Tomcat/apache-tomcat-7.0.26/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/apache-tomcat-7.0.26/bin/bootstrap.jar:/Library/Tomcat/apache-tomcat-7.0.26/bin/tomcat-juli.jar
Zerocools-Macbook:~ zerocool$ /Library/Tomcat/apache-tomcat-7.0.26/bin/shutdown.sh
Using CATALINA_BASE: /Library/Tomcat/apache-tomcat-7.0.26
Using CATALINA_HOME: /Library/Tomcat/apache-tomcat-7.0.26
Using CATALINA_TMPDIR: /Library/Tomcat/apache-tomcat-7.0.26/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/apache-tomcat-7.0.26/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Zerocools-Macbook:~ zerocool$

You may feel this as a very tedious method.So you can make this process uncomplicated by using an magnificent app which is known as Tomcat Controller.This app provides a simple start and stop button to start and stop the Tomcat server.

ImageImage

By default the Tomcat home directory is set to /usr/local/tomcat. This may not work as your tomcat is located at /Library/Tomcat/apache-tomcat-7.0.26. Change the Tomcat home directory in preferences to your own location of tomcat on your mac and have fun!

9 comments

  1. This how-to was just what I needed – thanks! One comment, though: once the /LibraryTomcat link is created, you don’t need to specify the target directory (you’ve got /Library/Tomcat/apache-tomcat-7.0.26/bin/startup.sh for example, and shouldn’t it be /Library/Tomcat/bin/startup.sh?) Also, great tip on Tomcat Controller – a real timesaver.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s