In this post, you will learn about download, install, configure and run Apache Tomcat server (version 10) on macOS operating system.

You know, Tomcat is a web server software developed by the Apache Software Foundation. Tomcat is free, open-source and widely used by developers/enterprises to run/host web applications built on Java EE platform.

 

Why Tomcat version 10 ???

Tomcat version 10 requires Java 11 or later, and it supports the following Java EE technologies: Servlet 6.0, JSP 3.1, EL 5.0, WebSocket 2.1, Authentication (JASPIC) 3.0, … that means you can use Tomcat 10 for running Java web applications built with Java 11 or later and Servlet 6.0 or older.

NOTE: it’s mandatory to have JDK installed on your macOS in order to run Tomcat because this server software is built in Java.

 

1. Download binary distribution of Tomcat 10

You need to download the archive file (zip or tar.gz) for macOS because no Tomcat installer provided for Mac. Click this link to visit Tomcat 10’s official download page. Find the download link for zip archive under the Binary Distributions section:

Tomcat 10 download page



Click the “zip” link (1) to download. You’ll get the file apache-tomcat-10.x.x.zip downloaded on your computer.

NOTE: Tomcat can be downloaded from mirror sites, so it’s strongly recommend to check SHA512 checksum of the downloaded file (link (2)).


2. Install Tomcat 10 on macOS

Before extracting the zip file, you should verify its integrity by checking SHA512 value of the file. In Terminal window, change the current directory to where the zip file is downloaded. And type the following command:

shasum -a 512 apache-tomcat-10.1.15.zip

It will hash the file to calculate SHA512 checksum value, as shown below:

checksum zip file of Tomcat 10

Compare this value against the one published on the download page (see link 2). If both are identical, that means the zip file is not tampered and safe to use.

To install, extract the zip file into a specific folder, e.g. user home directory, using the following command:

tar -xf apache-tomcat-10.1.15.zip -C $HOME

Then you can explore the files using some cd and ls commands, as shown below:

listing files of Tomcat 10

You know, Tomcat provides some shell script (.sh files) which can be found in the bin directory. These scripts can be used to control the server (start, stop, debug…). The primary scripts are:

  • catalina.sh: this is the general purpose script that can be used to check version, start, stop, debug the server…
  • version.sh: a shortcut to see version of the server, OS, JVM
  • startup.sh: a shortcut to start the server
  • shutdown.sh: a shortcut to stop the server
Next, let’s see how to start and stop Tomcat using shell scripts on macOS.


3. Start Tomcat server

In Terminal, change the current directory to bin, and execute one of the scripts above to start the server. For example:

./startup.sh

This will start a background thread that runs the server process. It will print something like this:

start Tomcat 10 command

This proves Tomcat has started. The server is listening on port 8080 (default port number of Tomcat) and is ready to serve requests from clients.

Now, open your web browser, and enter http://localhost:8080 into the address bar, you’ll see the server’s home page as shown below:

testing localhost Tomcat 10

Congratulations! You have installed Tomcat 10 successfully on your macOS. You can use this web interface you to deploy, manage, monitor Java web applications running on the server. Learn more: How to deploy a Java web application on Tomcat.

 

NOTES:

You can also use the following commands in Terminal to start Tomcat:

  • sh catalina.sh start
  • ./catalina.sh start
  • sh startup.sh
If you get permission denied error when running these scripts, you need to grant execute permission to the current user using the following command:

chmod u+x startup.sh


4. Stop Tomcat server

To shut down the running server, you can run the following command:

./shutdown.sh

The server process will be terminated, as shown below:

shutdown Tomcat 10

NOTES:

You can also use the following commands in Terminal to start Tomcat:

  • sh catalina.sh stop
  • ./catalina.sh stop
  • sh shutdown.sh
If you get permission denied error when running these scripts, you need to grant execute permission to the current user using the following command:

chmod u+x shutdown.sh


5. Configure access to Tomcat Web Application Manager

Developers can use the Tomcat Web Application Manager to deploy and manage Java web applications. It can be accessed by clicking the Manager App button on the localhost page. To sign in, you must enter correct username and password:

sign in Tomcat 10 manager app

But we have not configured any users yet, right? So click Cancel button. You will see 401 Unauthorized error page as shown below:

unauthorized error Tomcat 10

This page tells us how to update the tomcat-users.xml file, in order to get access to the Tomcat web application manager. Change the current directory to conf and edit the file using the following commands:

cd ../conf

open -a TextEdit tomcat-users.xml

open tomcat users xml file

This will open the TextEdit program that loads the tomcat-users.xml file. Remove the XML comments around <user> tags and keep only one username admin with your own password, as shown below:

edit tomcat users xml file

Save the change and quit TextEdit. You must stop and start the server for the change to take effect. Then you will be able to access the Tomcat Web Application Manager using the specified username and password:

tomcat web application manager

You can use this Tomcat Web Application Manager to deploy and manage Java applications running on the server. Check this article to learn about Java applications deployment on Tomcat.

Watch the following video to see how to download, install, configure and run Tomcat 10 on macOS in action:

 

Other Tomcat Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment