1、到Apache官方下载Mac版本的完整tar.gz文件。解压到资源库 /Library目录下,并命名为Tomcat。
2、修改目录权限
sudo chmod 755 /Library/Tomcat/bin/*.sh
3、启动Tomcat
sudo sh startup.sh
按回车后会提示输入密码,输入管理员密码后回车。如下表示成功。
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Tomcat started.
apache tomcat
注意:
1、如果是sh: startup.sh: No such file or directory这样的错误,则可以先
cd /Library/Tomcat/bin后是否看到startup.sh文件,再执行sudo sh startup.sh
2、如果提示
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
aplledeiMac:bin aplle$ vim ~/.bash_Profile
下载直接安装,安装成功后打开终端
打开配置文件 vim ~/.bash_Profile
按 i 编辑添加:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
在英文输入法按esc,然后shift+;键,wq! 保存
最后source ~/.bash_Profile执行
然后cd /Library/Tomcat/bin 执行sudo sh startup.sh就OK啦
截图 截图2
可以设置端口!
END.