How to Install Tomcat on Mac
How to Install Tomcat 7 on Mac
Step 1: Download and Install Tomcat
- Goto http://tomcat.apache.org ⇒ Download ⇒ Tomcat 7.0 ⇒
7.0.{xx}
(where{xx}
denotes the latest release) ⇒ Binary distribution ⇒ Core. Download the “tar.gz
” package (e.g., “apache-tomcat-7.0.{xx}.tar.gz
“).- Goto “
~/Downloads
“, double-click the downloaded TAR file (e.g., “apache-tomcat-7.0.{xx}.tar.gz
“) to expand it into a folder (e.g., “apache-tomcat-7.0.{xx}
“).(Notes for Advanced Users)
Alternatively, you can use thetar
command to expand the tarball as follow:$ cd ~/Downloads
$ tar xvf apache-tomcat-7.0.{xx}.tar.gz - Move the extracted folder (e.g., “
apache-tomcat-7.0.{xx}
“) to “/Applications
“. - Rename the folder “tomcat”, for ease of use.
- Goto “
- It is probably better to keep the tomcat in “
/usr/local
” or “/Library”. - Instead of renaming the tomcat’s folder, it it better to create a symlink called tomcat as follows:
$ cd /Applications
$ sudo ln -s apache-tomcat-7.0.{xx} tomcat - For security reason, you should not run Tomcat as root user. Instead, assign Tomat to user nobody (of group nobody):
$ sudo chown -R nobody:nobody /Applications/tomcat
// -R: recursive thru sub-directories
// {user}:{group}
// To start tomcat as user nobody
$ cd /Applications/tomcat/bin
$ sudo -u nobody ./startup.sh // No console message
$ sudo -u nobody ./catalina.sh run // See console message// To stop tomcat
$ sudo -u nobody ./shutdown.sh
(Notes for Advanced Users):
Step 2: Configure Tomcat Server
Read this to Configure Tomcat Server
Step 3: Start the Tomcat Server
To start the Tomcat server, open a new “Terminal” (Go ⇒ Utilities ⇒ Terminal) and issue:
$ ./catalina.sh run
Check for the Tomcat server’s TCP port number from the console messages. The default is 8080.
To verify if the Tomcat server is started, start a browser (Safari or Chrome) and issue URL http://localhost:9999, suppose that Tomcat is running on the TCP port number of 9999.
Step 4: Shutdown the Tomcat Server
To shutdown the Tomcat server, you can simply press control-c (NOT command-c) on the tomcat console, or issue command:
$ ./shutdown.sh