Skip to content

Instantly share code, notes, and snippets.

@emadpres
Last active May 18, 2025 19:53
Show Gist options
  • Save emadpres/a17c310b9be8c41dc632b5b699af2e1c to your computer and use it in GitHub Desktop.
Save emadpres/a17c310b9be8c41dc632b5b699af2e1c to your computer and use it in GitHub Desktop.
Installing Tomcat on MacOS

Install Tomcat (Source)

Prerequisite: Java

UPDATE: It seems the IntelliJ bundled java is suffient. So skip first two steps and don't mind java -version and echo $JAVA_HOME are not working.

  1. Check java -version. Tomcat 9.x requires Java 8 or later.

    java version "13.0.2" 2020-01-14

    Java(TM) SE Runtime Environment (build 13.0.2+8)

    • If you don't have: Download JDK from Here > Download JDK > jdk-13.0.2_osx-x64_bin.dmg (~ 173MB)
  2. Make sure echo $JAVA_HOME is set.

    /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home

    • If it's not set:
      1. Find Java Home (= the dir that contains Home/bin/) via /usr/libexec/java_home -verbose.
        • Probably: /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
      2. Add export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home to terminal profile (~/.zshrc or ~/.bash_profile)

Installing Tomcat 9

  1. Download a binary distribution of the core module: apache-tomcat-9.0.13 from here
    • I picked Binary Distributions > Core > tar.gz one.
  2. unarchiving the archive will create a new folder structure in your Downloads folder: ~/Downloads/apache-tomcat-9.0.13
  3. sudo mkdir -p /usr/local
    • -p = --parents = no error if existing, make parent directories as needed
  4. sudo mv ~/Downloads/apache-tomcat-9.xx /usr/local
  5. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat:
    • sudo rm -f /Library/Tomcat (First, remove old link, you might have from installing a previous version)
    • sudo ln -s /usr/local/apache-tomcat-9.xx /Library/Tomcat
  6. sudo chown -R <your_username> /Library/Tomcat
  7. sudo chmod +x /Library/Tomcat/bin/*.sh

Start Tomcat 9

  • start and stop like so:

    • /Library/Tomcat/bin/startup.sh
    • /Library/Tomcat/bin/shutdown.sh
  • After starting Tomcat, check out the default page at http://localhost:8080. It shows a lot of things, including a yellow cat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment