Install and run Tomcat on Mac

Apache Tomcat is an open source web server by Apache Software Foundation. Apache Tomcat is used to host Java server pages and Java Servlet. Basically its a Java web server. Its a well matured web server and largely used in the industry.

Install on Mac

Installing Tomcat on Mac is quite simple. Download the binaries from the Apache Tomcat website. Download the stable version from the website. There are Alpha, Beta and Stable versions are available on the  Tomcat site. At the time of writing this post Tomcat 8 version is latest and stable one. Download the tar.gz file. And extract on local disk. Before that make sure you have JDK installed on your Mac and Java Home variable is set.  Once you extract the files, that is it. You successfully install the Tomcat on your Mac.




Start and Stop Tomcat

To run Tomcat on mac, open the terminal window and goto bin folder of the extracted folder. Than run the following command on the terminal window ./catalina.sh start . If tomcat is successfully installed you will see the message Tomcat Started on the terminal window as you can see in the below screen shot.

Start Tomcat

Tomcat normally start at port 8080, if this port is not used by any other application. Browse the localhost with the following URL http://localhost:8080/ . And you will see a screen as shown below.

Tomcat localhost

To stop the Tomcat type the following command in terminal window ./catalina.sh stop .

Deploy WAR file

There are two ways to deploy a war file in Tomcat you can use anyone of it.

  1. Hot Deployment: It mean deploy WAR file when server is up and running.
  2. Cold Deployment: It means deploy WAR file when server is not running.

You can copy the war file on the following path of Tomcat /apache-tomcat/webapps . Once the WAR file is copied you will notice it will immediately extracted and a folder with the same name will be created.

Leave a Reply