- Installing Apache Tomcat on MacOS Mojave using Homebrew
- Installing JDK on Mac OS using Homebrew
- Step 1: Install Homebrew Cask
- Step 2: Install JDK with Homebrew Cask
- Installing and Running Apache Tomcat on Mac OS using Homebrew
- Step 1: Install Apache Tomcat
- Step 2: Run Apache Tomcat
- TomcatOnMacOS
- Running Tomcat on Mac OS X
- THE ENVIRONMENT
- THE SITUATION
- THE SOLUTION
- Updated for 2006
- Also Updated in 2010
- (1) Upgrade to Mac OS X 10.4.6
- (2) Download apache-tomcat-5.5.16
- (3) Fix the Unix file permissions
- (4) Start Tomcat
- (5) Test Tomcat
- (6) Start the Firewall
- (7) Enable Port-Forwarding
- (8) Test Tomcat
- (9) Walk the dog
- Updated for 2008
- Updated for 2009
- Updated for 2009
- How to Install Apache Tomcat on Mac OS X
- Install Tomcat
- Download the Apache Tomcat
- Change the permission
- Make the file executable
- Start the Tomcat by startup.sh
- Stop the server
Installing Apache Tomcat on MacOS Mojave using Homebrew
Aug 28, 2019 · 2 min read
In order to install Apache Tomcat on MacOS, we firstly need to install Java Development Kit(JDK). To check if java installed, open up the terminal and run the following command:
If the JDK is not installed, then you will be prompted with the following message
No Java runtime present, requesting install.
On the other hand, if JDK is installed, you will be promoted a message which will look similar to the following:
openjdk version “12.0.2” 2019–07–16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
Installing JDK on Mac OS using Homebrew
(If JDK is installed on your system, then please skip to the next section.)
Please make sure Hom e brew package manager is installed on your system. For instructions to install Homebrew please read the official documentation here.
Step 1: Install Homebrew Cask
Homebrew Cask extends Homebrew and allows you to install large binary files via the Mac terminal. JDK can be installed onto your Mac using Homebrew Cask.
In order to install Homebrew Cask, please type in the following commands onto the terminal sequentially
Step 2: Install JDK with Homebrew Cask
Run the following command to install the latest version of JDK onto your system:
Now, please check if Java is installed on your system by running the following command:
You will be promoted a message which will look similar to the following:
openjdk version “12.0.2” 2019–07–16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
Installing and Running Apache Tomcat on Mac OS using Homebrew
Step 1: Install Apache Tomcat
Run the following commands on the terminal in order to install Apache Tomcat:
Step 2: Run Apache Tomcat
Apache Tomcat can be run on Mac OS in two separate ways.
- Start Tomcat automatically at Mac Login:
In order to stop Tomcat to start automatically at Mac Login:
2. Start Tomcat manually:
In order to stop Tomcat manually:
To view available options on Tomcat run:
I hope this article has been to some aid to you. Would really love to hear from you!
Источник
TomcatOnMacOS
Running Tomcat on Mac OS X
[See below for later updates to this 2004 posting]
These notes are the result of several weeks playing with different things and asking a LOT of questions on several mailing lists.
I hope these notes are of use to someone out there.
THE ENVIRONMENT
Java is installed by default on every MacOS X installation. MacOS X 10.2 (Jaguar) comes with Java 1.3; MacOS X 10.3 (Panther) comes with Java 1.4. MacOS X 10.4 (Tiger) comes with Java 1.4.2 installed, but Java 1.5 can be downloaded. MacOS X 10.5 (Leopard) comes with Java 1.5. MacOS X 10.5 (Snow Leopard) comes with Java 1.6. It is possible to run Java 1.4 on MacOS X Jaguar but it may interfere with operation of the standard environment.
JAVA_HOME is at /Library/Java/Home , but this is a link into a directory /System/Frameworks/JavaJVM.Framework/Versions which is used to switch between versions easily. There is a link Current and CurrentVersion which matches up the current Java environment with the appropriate version.
THE SITUATION
I wanted to learn about Java Servlet Pages (JSP) on my Macintosh (with MacOS X). I installed it the first time on a Windows XP Professional system, but my development machine is a Macintosh.
THE SOLUTION
Since I had already installed and played with a separate install of Tomcat (the version installed by Apple’s XCode was out of date, as was the version I downloaded from another site), I was ready to give up!
In my case I wanted to get rid of all the other Tomcat installations and start from scratch.
Step 1: Download Tomcat
Download Jakarta Tomcat from the Tomcat home page, and get the binary version — I_downloaded jakarta-tomcat-5.0.27.tar.gz.
Extract the files (unless your browser automatically extracts them).
Navigate (using the Finder) to Macintosh HD > Library.
If there is not already a folder in Macintosh HD > Library called Tomcat, then create one.
If there is already a Tomcat folder (presumably from an out-of-date installation), delete all the files already in that folder.
Step 2: Extract tomcat archive
Copy all the unstuffed files from the jakarta-tomcat-5.0.27.tar.gz download and put all the files into the Tomcat folder.
I just named it Tomcat as it saves some typing in the Terminal
So the directory structure becomes:
Macintosh HD > Library > Tomcat >
Step 3: Configure tomcat-users.xml
Open the /Library/Tomcat/conf/tomcat-users.xml file with a plain text editor. The default Tomcat installation only has the basic roles and users set up.
What is configured as default is:
An example of what it should look like follows:
In this case a role, a user and password have been set up with the name tomcat. You can change this later.
Step 4: Start Tomcat
To start Tomcat, open a shell command prompt (using, for instance, the Terminal application).
The path to Tomcat via the Finder is Macintosh HD > Library > Tomcat.
But to get to that directory using the Terminal, type in:
Do an ls — you should see a file called startup.sh .
Any file in this directory ending in .sh can be executed in the terminal by putting a period and a slash before the file name (eg: startup.sh ). The following example executes the tomcat startup script:
Terminal should display four lines looking something like this:
There are some notes and a couple of Preference Panes for automating the starting and stopping of Tomcat. After trying them all on five different computers — this is the simplest!
Step 5: Test installation Open a browser window, and enter http://127.0.0.1:8080 — the default Tomcat page should open.
If you click the Tomcat Administrator or Tomcat Manager links in the upper left hand of the default Tomcat page, you will be asked for a user name and password.
As mentioned above, use tomcat for the user name, and tomcat for the password.
By : Brynley Blake (31 August 2004)
With considerable help from Joachim, Tracy, Tom, Samuel and Jonel from the Apple Web and Java Developer mailing lists.
Updated for 2006
Basil Bourque says:
Today (2006-04-05) I disovered a somewhat different recipe to running Tomcat 5.5.16 on Mac OS X 10.4.6.
- Today’s Tomcat (v5.5) wants to run on Java 5, but Apple’s command line defaults to Java 4 (1.4.2). Surprisingly, Tomcat’s script works around this.
- I did not need to set any environment variables (JAVA_HOME).
- But I did need to fix vital file permissions in the downloaded Tomcat folder.
Also Updated in 2010
By Pid: I removed some of the original statements about setting JAVA_HOME as they did not match my experience of installing Tomcat on OS X. It’s also certainly overkill to install an application just to be able to set an environment variable.
(1) Upgrade to Mac OS X 10.4.6
- I do not know if 10.4.6 is required, but it sure made an easy Tomcat install.
- Apply all of Apple’s Software Updates, especially the Java 5 update.
(2) Download apache-tomcat-5.5.16
- Unzip.
- Move it to your home folder.
(3) Fix the Unix file permissions
- Download the freeware BatChmod, a GUI wrapper around the Unix «chmod» command.
- Drag and drop the entire Tomcat folder onto the BatChmod icon.
- Check *all* the checkboxes.
- Click «Apply» and give your Administrator password.
(4) Start Tomcat
- Launch /Applications/Utilities/Terminal.
- Navigate to the Tomcat folder (apache-tomcat-5.5.16):
(5) Test Tomcat
- Launch a web browser such as Safari.
- Goto http://127.0.0.1:8080/
- You should see the cute Tomcat logo on the welcome page.
You are technically done at this point. But as a good pratice, I also did the following additional steps.
(6) Start the Firewall
- System Preferences > Sharing > Firewall > Start
- Also, click the Advanced button on that panel, to (a) block UDP, and (b) start logging. It is fascinating to see how quickly a computer directly on the Internet starts to get queried/tested/attacked. Open /Applications/Utilities/Console to see the log.
(7) Enable Port-Forwarding
- Add a rule to do port-forwarding from port 80 to Tomcat’s default port 8080. Type this in the Terminal:
The Sharing SysPref will get cranky when you add an ipfw rule behind its back; it disables its user interface. To use the Sharing SysPref again you’ll have to clear that rule, the one we added and numbered 100. To delete a rule, either read the ipfw man page, or use Simple Port Forwarder again. Quit the System Preferences program, and re-launch it to re-enable its Firewall panel.
(8) Test Tomcat
- Launch a web browser such as Safari.
- Goto: http://127.0.0.1/
Notice that we left off the port number this time, so the web browser defaults to port 80. Or you can explicitly say port 80: http://127.0.0.1:80/
- You should see the cute Tomcat logo on the welcome page.
- To be sure it is working, and not cached by the browser:
• Try another browser.
• Click the Reload button in the toolbar of the browser.
• Choose the Reload command, such as View > Reload Page in Safari.
(9) Walk the dog
- Enjoy an all-too-rare moment of computing satisfaction.
As best as I can recall, that is all I had to do today. I hope I am not steering you wrong. I did assume at first that Java 5 would not be used be default, so I wasted time messing with the path ($PATH) and setting the environment variable JAVA_HOME. But I undid those, as they failed. I then tried the simple steps above, and it worked.
I hope to refresh my own web site with this info: http://www.BasilBourque.org/
Tip: You can drag and drop from the Finder to the Terminal, to avoid typing file and folder names.
Updated for 2008
Michael Valentiner says:
Today (2008-02-03) I verified running Tomcat 6.0.14 on Mac OS X 10.5.1.
Like Basil, I did not need to set up JAVA_HOME and I did need to fix Unix file permissions.
Unlike Basil, the System Preferences > Sharing > Firewall has moved to System Preferences > Security > Firewall. I was able to enable logging, but haven’t figured out how to block UDP.
Updated for 2009
Chris Latko says:
To have Tomcat 6.0.x launch on boot on Mac OS X 10.5.x, you need to add a LaunchDaemon. Create a file called org.apache.tomcat.plist in /Library/LaunchDaemons/ with the following content:
Updated for 2009
Greg Woolsey says:
For Tomcat 5.5.x (and probably 6.0, as the scripts don’t appear to have changed much) you need a slightly modified plist, that calls catalina.sh in a manner compatible with the requirements of launchd: http://developer.apple.com/MacOsX/launchd.html. Specifically, the script must be run with the «run» parameter instead of «start», as start backgrounds the Java process and exits the script. This causes launchd to think the service is done, and kills the java process as part of it’s cleanup.
My plist assumes Tomcat is installed in /Library/Tomcat/tomcat-version, with a symbolic link called «Home» pointing to the version to use.
Save this file as /Library/LaunchDaemons/org.apache.tomcat.plist:
If you have a web app that doesn’t want to shut down nicely (my company’s product is one), then to avoid the need to force quit Tomcat just to turn off your Mac, use a startup script instead of a daemon plist.
Add this line to /etc/hostconfig as root:
Then, as root, create /Library/StartupItems/Tomcat, writable only by the owner (root).
Источник
How to Install Apache Tomcat on Mac OS X
Sep 15, 2018 · 3 min read
Install Tomcat
Download the Apache Tomcat
- Download the zip file or tar file
Change the permission
There is no executable permissions for the .sh files.
So we will change this permission by changing the permissions of these files.
Make the file executable
You just need to give a chmod here and then +x . +x is going to make this file executable and what are the files we want to make executable we want to make all .sh files so just give *.sh .
Now, you can see there is an x flag added to these files.
Start the Tomcat by startup.sh
Our purpose there are two files which are important one is this startup.sh to start the Tomcat and other is the shutdown.sh to shut down the Tomcat server.
So first of all I’m going to just execute the startup.sh message file so you just need to just give this come on dot forward slash so just give dot forward and the startup.sh and this will execute this startup shell script.
You can see the last message here “Tomcat started”.
Now how to check whether Tomcat that is properly started or not I’m going to go to my browser and in here I will just write localhost:8080 . The port 8080 is the default port for the Tomcat to start.
You will be able to see this kind of interface and that means your Apache server is running fine.
Stop the server
Now to stop your server you just need to run the stop script so you just need to write shutdown.sh .
Once you run this and refresh the localhost:8080 page now nothing is shown here, so our Apache Tomcat server is stopped.
Источник