Continuous Integration: Tomcat Setup


In this tutorial series we will explore a rarely discussed (but highly valuable) process of developing software that is disappointingly absent in the iOS and mobile world: Continuous Integration.

Also available in this series:

  1. Continuous Integration: Series Introduction
  2. Continuous Integration: Tomcat Setup
  3. Continuous Integration: Hudson Setup
  4. Continuous Integration: Scripting Xcode Builds
  5. Continuous Integration: Script Enhancements

Where We Left Off

In part 1 we introduced Continuous Integration as a way to improve the software development process and reduce the time we spend integrating code, building and signing our apps and distributing them for use.

Introducing Apache Tomcat

Apache Tomcat (or just Tomcat) is an open source web server that supports Java Servlet and JavaServer Pages. Tomcat is required because our CI software of choice (Hudson) is written in Java and needs a web server to run on. As you will soon find out, Tomcat is relatively easy to set up but configuring it for proper use can be a little tricky. We'll go through it step by step.

Step 1: Check System Requirements

Please check your system meets the following software requirements:

  • OSX Snow Leopard or Higher
  • Xcode 4.0 or higher
  • Java 1.6 or higher

To check what version of Java you have installed, open a terminal window and enter:

java -version

If you have Snow Leopard installed, this should be fine. If you are running Lion, you might not have Java installed. If it needs to be installed go to and follow the instructions install the latest version.

Step 2: Download Tomcat

Navigate to and download the 'tar.gz' in the 'Core' section in Binary Distributions. Go to your downloads folder, unarchive the download and then rename the folder to something a bit more human readable. I'm going to call mine "tomcat".

Step 3: Install Tomcat

Tomcat can be placed anywhere on the OS X file system, however, it is best to place it in the '/usr/local' directory. We're going to do all this using the unix terminal, so open up a new terminal and navigate to your downloads directory using the 'cd' (change directory) command:

cd /Users/username/Downloads

Next, move the tomcat directory to the /usr/local directory using the 'mv' command:

mv tomcat/ /usr/local

Tomcat is sitting in the /usr/local directory and ready to be used! Before we can start it up though, we need to do a few things.

Step 4: Configure Tomcat

If we try and start up Tomcat now, we will run into a few ownership and permission errors. We need to tell the file system that you own that folder and have permission to use it.

First, navigate to the /usr/local directory:

cd /usr/local

Next, we need to make sure the owner of the tomcat folder (and all the sub files and folders) is us. To change the owner of something on unix, we use the 'chown' command:

sudo chown -R username tomcat

Making changes like permissions or file ownership requires administrative privileges. Typing "sudo" before the command tells terminal we are an administrator. If we can prove it by entering a valid password, then the command is executed.

We also need to make some scripts executable, so the server can do its thing:

sudo chmod +x tomcat/bin/*.sh

This makes all the files that end in '.sh' in tomcats bin folder executable.

Finally, before we start we need to increase the amount of virtual memory that tomcat can use. Its default amount is 64 mb and this is sometimes not enough, especially when we are working with large projects.

To do this, we need to edit a configuration file in the tomcat directory. Open a finder window and in the top menu navigate to "go->Connect to server". In the window that pops up, enter:


Find the "" file and open it in a text editor. If you are looking for a great and
free text editor, I recommend you checkout text-wrangler at Around line 100 (below the #OS Specific support comment) add the following line:

export JAVA_OPTS="-Xms128m -Xmx512m"

This line sets two variables. Xms defines the memory that your tomcat server starts with. Xmx sets the maximum amount of memory that your server can use.

Step 5: Starting And Stopping Tomcat

We're ready to start Tomcat up! To start the server, we need to execute a startup script found in tomcat's bin folder. So, open a terminal and run the follow command:


If all goes well, you should see something like this in your terminal window:

Now, open a browser and enter the following into your browser bar:


Lo' and behold, we have a running instance of Tomcat!

If you ever need to stop tomcat (restarting after a config edit for instance), all you need to do is run this script from the terminal:


Next Time

In the next article, we're going to install our CI server, "Hudson" and configure it to work with our svn or git project using either ssh or https authentication. We'll also have a dig inside the hudson directory to get an understanding of how it stores and works with the files. Catch you next time!

Related Posts
  • Code
    Installing WordPress in the Amazon CloudCloud
    This guide will provide you a detailed, step by step approach to setting up your WordPress blog at AWS in a high performance, economical fashion using an AWS micro (or small) instance running on Apache. A follow up tutorial covers how to optimize its performance with Varnish Cache and the W3 Total Cache plugin. Using these approaches, I've successfully run my own site in the Amazon cloud for the past two years and survived many mentions on Slashdot, BoingBoing and other high traffic sites.Read More…
  • Code
    Using WP-CLI with Mina Preview template
    WP-CLI is a great tool that allow you to control WordPress from command line without touching the WordPress dashboard. However, manually logging into the server and run a command every time is painful. It's time consuming. In this tutorial, I will show you how we can combine these commands into Mina tasks and invoke them from our local machine to run on remote machine.Read More…
  • Code
    Web Development
    How to Use New Relic With PHP & WordPress20465
    Today we will look at how to monitor a PHP application using New Relic. More specifically we will set up a basic WordPress installation and get some performance data about it, in the New Relic dashboards.Read More…
  • Code
    Web Development
    Easily Deploy Redis Backed Web Apps With DockerDocker wide retina preview
    Learn how to setup and deploy a Redis powered Python web app using Docker.Read More…
  • Computer Skills
    How to Control a Lamp With Voice Commands and a Raspberry PiPivoice400
    Voice control is not just for smart phones and B-movies anymore. Steve Hickson has created a system to bring automation and the intelligence of Wolfram Alpha to your beck and call. In this tutorial I'll show you how to install Voice Command, configure it, and teach it to turn a lamp on and off. The control of mains power is a tricky and dangerous subject for hobbyists so you'll be using a prebuilt solution for controlling the voltage to the lamp.Read More…
  • Code
    Setting Up a Local Mirror for Composer Packages With SatisComposer retina preview
    Installing all your PHP libraries with Composer is a great way to save time. But larger projects automatically tested and run at each commit to your software version control (SVC) system will take a long time to install all the required packages from the Internet. You want to run your tests as soon as possible through your continuous integration (CI) system so that you have fast feedback and quick reactions on failure. In this tutorial we will set up a local mirror to proxy all your packages required in your project's composer.json file. This will make our CI work much faster, install the packages over the local network or even hosted on the same machine, and make sure we have the specific versions of the packages always available.Read More…