Installing Tomcat 8 on OS X 10.11 El Capitan

2016/07/27 14:19
阅读数 127

By far the easiest way to install and configure an Apache Tomcat server on a mac is using thehomebrew package management suite. If you’re not already using homebrew, you should be. It can be installed via the instructions on their website, it makes open source package management on mac 100 times easier than doing it manually.

There is a good tutorial here on installing homebrew if you do already not have it.

First install with the brew install in terminal:

$ brew install tomcat

This will take care of the downloading, installation and configuration of not only Tomcat but any dependencies as well.

Homebrew keeps packages (known as “kegs”) in a “Cellar”, a directory typically located at:

/usr/local/Cellar/

To start the Tomcat server, execute the Catalina shell program with the “run” parameter as such:

$ ls /usr/local/Cellar/tomcat/
$ /usr/local/Cellar/tomcat/[version]/bin/catalina run

The version number and installation directory will have been listed by homebrew at the end of the installation output (typically the last line with a beer symbol in front). Catalina can also be set to start on system launch – although for security reasons we prefer to only run when needed (either using this command or more commonly via an IDE plugin).

Once the server is running you can navigate to the host page at:

http://localhost:8080/

To add and manage applications running on the server you will also need to edit a configuration file:

$ vim /usr/local/Cellar/tomcat/[version]/libexec/conf/tomcat-users.xml

With [version] again replaced with your installed version. Towards the bottom of this short config file you will see a selection of users – all commented out by default. You need to uncomment one of these and give it the extra role “manager-gui” (preferably also changing the username and password for security). The resultant user entry should look something like this:

<user username="admin" password="password" roles="tomcat,manager-gui" />

After this you can navigate to the page (or click the “Manager App” link on the main Tomcat Server page):

http://localhost:8080/manager/html

Here you can view or delete the included sample application and deploy your own. Usually it’s easiest to deploy applications in a dev / testing environment using an IDE or other deployment routine, however the web interface is fine also. For reference, deployed applications are usually then located under the directory:

/usr/local/Cellar/tomcat/[version]/libexec/webapps/

展开阅读全文
打赏
0
0 收藏
分享
加载中
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部