Click the “zip” link (1) to download. You’ll get the file apache-tomcat-8.5.x.zip downloaded on your computer.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: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:chmod u+x startup.sh
sh catalina.sh stop
Tomcat will be stopped, as shown below:
NOTES:You can use the following commands in Terminal to start Tomcat:chmod u+x shutdown.sh
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:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.