install tomcat 7 on mac

Tomcat 7 is the first Apache Tomcat release to support the Servlet 3.0, JSP 2.2, and EL 2.2 specifications. Please note that Tomcat 7 requires Java 1.6 or better, but that shouldn’t be a problem, if you are running OS X 10.5 or 10.6.

On OS X 10.7 (Lion) however, Java is initially not installed anymore. You can find the installer on Apple’s support side

here or follow this installation  guide, provided by Adobe. Whatever you do, when opening Terminal and running java -version, you should see something like this.
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3646)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)

Here are the easy to follow steps to get it up and running on your Mac

  1. Download a binary distribution of the core module: apache-tomcat-7.0.27.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
  2. Opening/unarchiving the archive will create a folder structure something like this in you Downloads folder: (btw, this Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
    ~/Downloads/apache-tomcat-7.0.27
  3. Move the unarchived distribution to /usr/local
    sudo mkdir /usr/local
    sudo mv ~/Downloads/apache-tomcat-7.0.27 /usr/local
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat:
    sudo ln -s /usr/local/apache-tomcat-7.0.27 /Library/Tomcat
  5. Change ownership of the /Libaray/Tomcat folder hierarchy:
    sudo chown -R <your_username> /Library/Tomcat
  6. Make all scripts executable:
    sudo chmod +x /Library/Tomcat/bin/*.sh
  7. sudo chmod 755 /Library/Tomcat/bin/*.bat 
  8. 遇见”JAVA_HOME not defined”JAVA路径未定义错误,在终端中执行以下命令: 

    sudo setenv JAVA_HOME /Library/Java/Home 

  9. 配置Tomcat启动脚本: 

    使用文本编辑器添加以下代码: 

    #!/bin/bash 

    case $1 in 
    start) 
    sh /Library/Tomcat/bin/startup.sh 
    ;; 
    stop) 
    sh /Library/Tomcat/bin/shutdown.sh 
    ;; 
    restart) 
    sh /Library/Tomcat/bin/shutdown.sh 
    sh /Library/Tomcat/bin/startup.sh 
    ;; 
    *) 
    echo “Usage: start|stop|restart” 
    ;; 
    esac 

    exit 0 

    将文件保存为tomcat,小写并不带后缀。将这个文件放置到终端包含的路径中,例如/usr/bin,而后便可以在终端中简单地输入tomcat start和tomcat stop启用tomcat了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值