1.到apache官网下载Tomcat安装文件:http://tomcat.apache.org/
点击Download中的版本,我选择的是7.0,下载Core中的zip包或tar.gz包:
2.解压安装包,将解压后的apache-tomcat-7.0.47移动到你的理想位置。
3.打开终端,输入命令:sudo sh startup.sh所在的完整路径,注意startup.sh的后缀sh不能少。
sudo sh /Users/apple/apache-tomcat-7.0.47/bin/startup.sh
启动Tomcat成功。
停止Tomcat的方法,输入以下命令:sudo sh shutdown.sh文件路径
sudo sh /Users/apple/apache-tomcat-7.0.47/bin/shutdonw.sh
4.配置Tomcat的端口号和管理用户。
打开server.xml,找到以下选项并配置:
<Connector port="9000" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
打开tomcat-user.xml,编辑以下选项:
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->
<!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
<user username="admin" password="admin" roles="admin,manager,role1,tomcat,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
</tomcat-users>
此时可以直接使用用户名和密码均为admin的账号登陆管理。
5.成功标志:打开浏览器,输入http://localhost:端口号/(注意startup不能停),再登陆看看。如果成功,那就没问题了。
这里我没遇到网上所说的一些文件权限问题,所以感觉Mac配置Tomcat比Windows方便太多了。