Apache Tomcat on Mac
Back to current version Restore this version

Install Apache Tomcat 6#

On OS X, the JAVA_HOME environment variable must be set to /Library/Java/Home directory, which in turn is a symbolic link that points to the current version of Java SDK you are running.

Edit .bash_profile#

Add the following lines to the .bash_profile file:

Note: DO NOT PUT A TERMINATING SLASH at the end of these lines - e.g. /Library/Java/Home/

export JAVA_HOME=/Library/Java/Home
export CATALINA_HOME=/Library/Tomcat/Home

Afterwards, save file and restart terminal.

Verify#

Execute an env command to make sure JAVA_HOME and CATALINA_HOME are set correctly.

env

Download and install the Tomcat binaries#

Download Tomcat 6 Binary Distribution Core (tar.gz) and Deployer (tar.gz) from the Apache Tomcat 6 Downloads Page. Download the Core apache-tomcat-6.0.x.tar.gz.

Create the Tomcat folder in an appropriate directory - /Library or /usr/local is recommended, but for development convenience Tomcat can be also installed in your home directory.

Execute the following commands in Terminal:

Change directories to Library or /usr/local

cd /Library

Create the Tomcat directory and set an appropriate owner and group

mkdir Tomcat
chown <username> Tomcat
chgrp admin Tomcat

Change directories to the newly created Tomcat directory and unpack the tar.gz files

cd Tomcat
tar -xvzf ~/Downloads/apache-tomcat-6.0.x.tar.gz

Create a symbolic link that will always point to the current version Tomcat directory

ln -s apache-tomcat-6.0.x Home

Edit tomcat-users.xml configuration file#

Execute the following commands in Terminal:

Change directories to the Tomcat configuration directory

cd Home/conf

Edit the tomcat-users.xml file

nano tomcat-users.xml

Add the following, where <admin> is the administrator name you assign and <password> is the password.

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

The tomcat-users.xml file should look something like this:

<tomcat-users>
<!--
<roll rollname="tomcat"/>
<roll rollname="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat" />
<user username="role1" password="tomcat" roles="role1" />
<user username="both" password="tomcat" roles="tomcat,role1" />
-->
<user username="<admin>" password="<password>" roles="standard,manager,admin"/>
</tomcat-users>

Save the tomcat-users.xml file and quit the editor

Run and Test#

Change directories to where the Tomcat startup scripts are located

cd ../bin

Remove the .bat scripts and .exe executables

rm *.bat *.exe

Execute the Tomcat startup script

./startup.sh

From your web browser go to the URL http://localhost:8080/

You should see the Tomcat welcome screen.

Use the ./shutdown.sh script to stop Tomcat.

Reference#

This information taken from http://www.malisphoto.com/tips/tomcatonosx.html. It has much more information and is very good.


Mac - Tomcat - Networking