下载Tomcat
tomcat.apache.org/download-90…
解压至Library/apache-tomcat-9.0.8/文件夹下,可以直接拖动压缩包到Library目录,双击解压,删除压缩包即可
配置环境变量
终端输入 vim ~/.bash_profile 如果没有bash_profile则需要先创建
添加Tomcat环境变量配置
#tomcat配置
CATALINA_BASE=/Users/xxx/Library/apache-tomcat-9.0.8
CATALINA_HOME=/Users/xxx/Library/apache-tomcat-9.0.8
export PATH=$PATH:/Users/xxx/Library/apache-tomcat-9.0.8/bin
export CATALINA_BASE CATALINA_HOME
运行Tomcat
需要进入Tomcat下的bin目录进行运行,即使配置了环境变量仍然会报一下错误
xxxxxx@bogon:~|⇒ sh startup.sh
Cannot find ./catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program
xxxxxx@bogon:~|⇒
终端进入/Users/xxx/Library/apache-tomcat-9.0.8/bin目录,输入sh startup.sh启动Tomcat
此时在浏览器中输入 http://loacalhost:8080
关闭Tomcat
终端 xxx/bin 目录下,输入sh shutdown.sh 关闭Tomcat