neutrofoton

Science, Technology and Life

Install Tomcat in OS X 10.8 Mountain Lion

| Comments

In this blog post will show us about step installing Apache Tomcat on OS X Mountain Lion. I assume we already have Java installed on our machine. The first step is downloading Tomcat binary distribution in Tomcat website. In this case I use version 7.0.30.

Extract the downloaded binary distribution onto ~/Download/apache-tomcat-7.0.30. Create directory in /usr/local if we don’t have it yet.

tomcat installation
1
sudo mkdir /usr/local

Move ~/Download/apache-tomcat-7.0.30 to /usr/local

tomcat installation
1
sudo mv ~/Downloads/apache-tomcat-7.0.30 /usr/local

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. Then we also will change owner and make script executable

tomcat installation
1
2
3
sudo ln -s /usr/local/apache-tomcat-7.0.30/ /Library/Tomcat
sudo chown -R neutrocode /Library/Tomcat
sudo chmod +x /Library/Tomcat/bin/*.sh

The next step is creating user for tomcat admin by editing tomcat-user.xml

tomcat installation
1
vi /Library/Tomcat/conf/tomcat-users.xml
tomcat-users.xml
1
2
3
4
5
6
7
8
9
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>

<user username="admin" password="password" roles="admin-gui,admin-script" />
<user username="manager" password="password" roles="manager-gui,manager-script,manager-jmx,manager-status" />

Add the following text in current user profile .bash_profile

.bash_profile
1
2
3
4
export CATALINA_HOME=/Library/Tomcat
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

export PATH=$JAVA_HOME:$PATH

Start the server with the following command :

start tomcat
1
$CATALINA_HOME/bin/catalina.sh start

or

start tomcat
1
$CATALINA_HOME/bin/startup.sh

Stop the server with the following command :

start tomcat
1
$CATALINA_HOME/bin/catalina.sh stop

or

start tomcat
1
$CATALINA_HOME/bin/shutdown.sh

Comments