Apache tomcat is a widely used web server. It can be installed an run in numerous operating system like Windows, Linux and MacOS. This article will tell you how to install it in MacOS step by step. But before install it, you should enable root user in MacOS following article How To Enable Root User Or Change Root Password In MacOS
1. Install Apache Tomcat In MacOS Steps.
- First make sure you have installed jdk in MacOS, run
java -version
in terminal to get the installed version. If you do not have installed jdk, you need to download and install one.sh-3.2# java -version java version "1.8.0_172" Java(TM) SE Runtime Environment (build 1.8.0_172-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
- Download tomcat install package from https://tomcat.apache.org/download-90.cgi page. You can select zip file or tar.gz file.
- After download, unzip the compress file to a local directory.
- Run cd go to the unzip file directory.
- Then run below command to make the .sh file executable.
sh-3.2# cd /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8
sh-3.2# sudo chmod +x ./bin/*.sh
- Now all the .sh file in tomcat bin directory is executable, you can run
ls -al
command to see that. - now run ./bin/startup.sh to start tomcat. When you see below message, it means tomcat has been started successfully.
sh-3.2# ./bin/startup.sh Using CATALINA_BASE: /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8 Using CATALINA_HOME: /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8 Using CATALINA_TMPDIR: /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8/temp Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home Using CLASSPATH: /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8/bin/bootstrap.jar:/Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8/bin/tomcat-juli.jar Tomcat started.
- Now open a web browser, input http://localhost:8080/ in the url address input box. Click enter then you can see below web page.
- To stop tomcat, you can run
./bin/shutdown.sh
command in terminal.
2. How To Change Tomcat Default Listening Port Number.
Tomcat default listen on port 8080. When you meet error during startup tomcat, the reason maybe that port number has been used by other progress. So you need to change the port number to what you need. Below is the steps to change tomcat server http port number.
- Open tomcat-install-directory/conf/server.xml file in a file editor. In my environment, the server.xml located at /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8/conf/server.xml.
- Find below connector configuration in server.xml file. And change the port number from 8080 to what you want such as 8089
<Connector port="8089" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
- Save above settings and start tomcat again, now you can access tomcat from new url http://localhost:8089/.
Thank you!
Great job.
Hubert.
Nice explanation and straight to the point.
Thank you.
Perfect! Nice and easy!!
Thanks
worked like a charm. Thanks a million
Simple , neat and easy!
Good job!!!!!
Worked like a charm.
Nice explanation and straight to the point.
Thank you.
Thank you!
Muito Obrigado!
Deu certo.