<< Creating GMock expectations for methods that have a closure as a parameter | Home | 34 Pin IDC to 25 Pin Female D-Sub floppy drive pin mapping for Magic Super Griffin >>

No-Fuss Tomcat 5.5 installation on OSX 10.5 (December 2009)

After a bit of googling on the topic I couldn't find a decent guide of how to install Tomcat 5.5 on OSX.  Here's how I did it.

Download the apache-tomcat-5.5.28.zip zip file from 'Core' section of the Tomcat 5.5 download page from here: http://tomcat.apache.org/download-55.cgi
Download the apache-tomcat-5.5.28-admin.zip zip file from the same page

Open a terminal window.

# perform following operations as root
sudo su -

# unpack tomcat
cd /Library
unzip ~/downloads/apache-tomcat-5.5.28.zip
unzip ~/downloads/apache-tomcat-5.5.28-admin.zip
mv apache-tomcat-5.5.28 Tomcat5

# remove the holding page for the message about the admin webapp not being included by default
rm -rf /Library/Tomcat5/webapps/ROOT/admin

# create tomcat group and user
dscl . -create /groups/tomcat
dscl . -create /groups/tomcat Password "*"
dscl . -create /groups/tomcat PrimaryGroupID 498
dscl . -create /groups/tomcat RealName "Apache Tomcat Users"
dscl . -create /users/tomcat
dscl . -create /users/tomcat Password "*"
dscl . -create /users/tomcat UniqueID 498
dscl . -create /users/tomcat PrimaryGroupID 498
dscl . -create /users/tomcat RealName "Apache Tomcat Server"
dscl . -create /users/tomcat NFSHomeDirectory /var/empty
dscl . -create /users/tomcat UserShell /usr/bin/false

# Hide the tomcat user (and all other users with a UniqueID less than 500) from the Mac OS X GUI
defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool true

# fix permissions
cd /Library
chown -R tomcat:tomcat Tomcat5
chmod +x Tomcat5/bin/*.sh

# use a text editor to create a launch script
mate /Library/LaunchDaemons/org.apache.tomcat5.plist

paste in the following xml content and save the file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>EnvironmentVariables</key>
        <dict>
            <key>CATALINA_HOME</key>
            <string>/Library/Tomcat5</string>
            <key>CATALINA_OPTS</key>
            <string>
                -server
                -Xmx256m
                -Dfile.encoding=UTF-8
                -Djava.awt.headless=true
                -Duser.language=en
                -Duser.timezone=GMT+0
            </string>
            <key>JAVA_HOME</key>
            <string>/Library/Java/Home</string>
        </dict>
        <key>KeepAlive</key>
        <dict>
            <key>SuccessfulExit</key>
            <true/>
        </dict>
        <key>Label</key>
        <string>org.apache.tomcat5</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Library/Tomcat5/bin/catalina.sh</string>
            <string>run</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>tomcat</string>
    </dict>
</plist>

Configure the tomcat users

mate /Library/Tomcat5/conf/tomcat-users.xml

paste in the following xml content and save the file

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="admin" password="secret" roles="admin,manager"/>
</tomcat-users>

Finally, start tomcat

launchctl load -w /Library/LaunchDaemons/org.apache.tomcat.plist

You can now start your browser and point it to:

http://localhost:8080

You can login to both the manager application and the admin application using the username: 'admin' and the password: 'secret'




Send a TrackBack