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.
4、打开浏览器,输入http://localhost:8080回则看到这样的界面表示成功:
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
则需要安装Java环境,下载<a href="https://www.baidu.com/s?wd=java%20jdk&rsv_spt=1&rsv_iqid=0xa6440b0e00002461&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=1&rsv_t=21daP%2Fv4mtMVfGI17lXrIjj%2FPeuKfq2ebOILV%2FKhxiYpomEPVK8kObkJjCbrPFm1uBKT&oq=sdk&rsv_pq=90daf63c000005b9&rsv_sug3=32&rsv_sug1=17&rsv_sug7=101&rsv_sug2=0&inputT=41551&rsv_sug4=42080">java jdk下载</a>
下载直接安装,安装成功后打开终端
打开配置文件 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啦
为了方便,下载<a href="http://www.activata.co.uk/tomcatcontroller/">Tomcat Controller</a>
截图 截图2可以设置端口!
END.
网友评论