How to install Tomcat in Mac OS

How to install Tomcat in Mac OS

 1. Check that java is installed in your computer

By default MAC comes with java installed, you do not have to do anything special expect that you want an specific java version running.

Open a Terminal and do the check:

$ java -version

java version “1.6.0_51”

Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)

Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

2. Download the apache tomcat

Tomcat is software that permits a web request to be directed to a piece of Java code (servlet) with some associated infrastruture to handle cookies and request/reply coordination. These functions are collectively referred to as a “web container”.   Tomcat used to also be referred to as Catalina. The Catalina name is still used in some of the config setup below

 Download Tomcat 7 Binary Distribution Core (tar.gz) from the Apache Tomcat 7 Downloads Page and uncompress it into a directory of your choice.

Copy the files to your /usr/local folder:

$ sudo mv /Users/<your_user>/Downloads/apache-tomcat-7.0.53.tar.gz /usr/local

Uncompress the downloaded file:

$ sudo gnutar -xzvf apache-tomcat-7.0.53.tar.gz

Now you are ready to startup, use and shutdown yout Toncat server:

$ cd apache-tomcat-7.0.53/bin/

$ ./startup.sh

At this point you can test that your sever is up and running from a navigator with http://localhost:8080/

You can shutdown the server just typing:

$ ./shutdown.sh

3. Set the environment variables

Edit the bash profile with an editor like vi and add the following lines:

$ sudo vi ~/.bash_profile

# Tomcat entries

export CATALINA_BASE=”/usr/local/apache-tomcat-7.0.53″

export CATALINA_HOME=”/usr/local/apache-tomcat-7.0.53″

export CATALINA_TMPDIR=”/usr/local/apache-tomcat-7.0.53/temp”

Save it and reload the bash profile:

$ . ~/.bash_profile

4. Deploy and test an application

copy or deploy your test application with its own folder in /usr/local/apache-tomcat-7.0.53/webapps/myTestApp

Open a navigator and type test your URL: http://localhost/myTestApp/myIndex.jsp

Advertisements

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