Mac下Tomcat环境的搭建

1、Apache Tomcat 官网下载tomcat版本,本文下载:apache-tomcat-9.0.0.M1.tar.gz 文件。

2、加压apache-tomcat-9.0.0.M1.tar.gz
tar xzvf apache-tomcat-9.0.0.M1.tar.gz

3、将解压文件移到存放目录,如放到:localbin目录下
mv apache-tomcat-9.0.0.M1 /Users/$USER/localbin

4、添加可执行权限:
chmod -R 775 apache-tomcat-9.0.0.M1

5、创建tomcat文件添加下面内容(可以从评论中找到该文件):
#!/bin/bash

TOMCAT_HOME=/Users/$USER/localbin/apache-tomcat-9.0.0.M1

case $1 in
start)
sh ${TOMCAT_HOME}/bin/startup.sh
;;
stop)
sh ${TOMCAT_HOME}/bin/shutdown.sh
;;
restart)
sh ${TOMCAT_HOME}/bin/shutdown.sh
sh ${TOMCAT_HOME}/bin/startup.sh
;;
*)
echo "Usage:tomcat start|stop|restart"
;;
esac

exit 0

6、给tomcat文件添加可执行权限。

7、在~/.bash_profile 文件中添加如下环境变量:
vi ~/.bash_profile export TOMCAT_HOME=/Users/allison/localbin/apache-tomcat-9.0.0.M1 export PATH=${PATH}:${TOMCAT_HOME}/bin

8、使用修改的文件生效,说明每次打开终端是环境变量生效都需要执行下面命令。
source ~/.bash_profile

本文参考:freeyiyi1993的博客

posted @ 2016-01-27 11:28  Forrest.Wang  阅读(181)  评论(0编辑  收藏  举报