Download and Install Tomcat 8.5 on macOS
- Details
- Written by Nam Ha Minh
- Last Updated on 13 November 2023   |   Print Email
1. Download binary distribution of Tomcat 8.5
There’s no Tomcat installer for macOS, so you need to download an archive file (zip or tar.gz) and install manually. Click this link to head over to the official download page of Tomcat 8.5. Look at the Binary Distributions section:Click the “zip” link (1) to download. You’ll get the file apache-tomcat-8.5.x.zip downloaded on your computer.
2. Install Tomcat 8.5 on macOS
It’s strongly recommended verify integrity of the downloaded zip file to make sure it is not tampered by hackers. Open a new Terminal window, change the current directory to where the zip file is stored. Then type the following command:shasum -a 512 apache-tomcat-8.5.95.zip
You should get the following SHA512 checksum of the file:Compare this hash value against the one published on the download page (click the “sha512” link (2) next to download link). If both are identical, that means the download file is safe to use.Then extract the zip file into a specific folder, e.g. user home directory, using the following command:tar -xf apache-tomcat-8.5.95.zip -C $HOME
Then perform some cd and ls commands to see the files extracted:Go to bin directory and you see some shell script files (.sh) which can be used to control the server (start and stop). Here I name the primary ones:- catalina.sh: the general purpose script. Used this 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
3. Start Tomcat server
Make sure that bin is the current directory, type the following command in terminal to start Apache Tomcat server:sh catalina.sh start
This will run Tomcat in a separate thread other than the Terminal window thread. You should see the following output:That means Tomcat started, is listening on port 8080 (default) and is ready to receive requests. Open your web browser, and enter http://localhost:8080 into the address bar, you’ll see the server’s home page as shown below:This web interface allows 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 use the following commands in Terminal to start Tomcat:- ./catalina.sh start
- sh startup.sh
- ./startup.sh
chmod u+x startup.sh
4. Stop Tomcat server
To shut down the running server, you can run the following command:sh catalina.sh stop
Tomcat will be stopped, as shown below:NOTES:You can use the following commands in Terminal to start Tomcat:- ./catalina.sh stop
- sh shutdown.sh
- ./shutdown.sh
chmod u+x shutdown.sh
5. Add a user to access Tomcat Web Application Manager
The Tomcat Web Application Manager allows us to deploy and manage Java web applications. It can be accessed by clicking the Manager App button on the localhost page. You will be asked for username and password:But we have not configured any users yet, right? So click Cancel button. You will see 401 Unauthorized error page as shown below:Read this page and you can see it instructs how to add a user in order to get access to the Tomcat web application manager. Change the current directory to conf and edit the tomcat-users.xml file using the following commands:cd ../conf
open -a TextEdit tomcat-users.xml
This will open the TextEdit program to edit the file. Remove the XML comments around <user> tags and keep only one username admin with desired password, as shown below:Close the program to save the change. Stop and start the server, then you will be able to access the Tomcat Web Application Manager using the specified username and password:You can use this interface to deploy and manage Java applications running on the server. Check this article to learn about deployment of Java applications on Tomcat.Watch the following video to see the steps of setup Tomcat 8 on macOS in action:Other Tomcat Tutorials:
- How to deploy a Java web application on Tomcat
- How to Embed Tomcat Server into Java Web Applications
- How to Use Virtual Hosts in Tomcat
- How to configure JNDI DataSource for Database Connection Pooling in Tomcat
- How to configure session timeout in Tomcat
- How to change Tomcat port number
- How to add Tomcat server in Eclipse
- How to change server location and deploy path for Tomcat in Eclipse
Comments