天天看點

Mac OS X 系統安裝 Tomcat 7.0.x 簡明教程

<a target="_blank" href="http://wolfpaulus.com/jounal/mac/tomcat7/comment-page-4/#comment-11005">Installing Tomcat 7.0.x on OS X</a>

While Tomcat 8 is close to be released (Tomcat 8.0.0-RC5 (alpha) is released already), Tomcat 7 was 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, which

shouldn’t be a problem, if you are running OS X 10.5 or 10.6.

OS X 10.7, 10.8 (Mnt Lion), and 10.9 (Mavericks) however, Java is not installed anymore, at least not initially. The easiest way to get Java onto your Mac is probably to open the Terminal app and enter java. You will be asked if you want to install it and

OS X takes care of the rest – you would end up with Java 6.

<a target="_blank" href="http://wolfpaulus.com/wp-content/uploads/2012/10/mav.png"></a>

The JDK installer package come in an dmg and installs easily on the Mac; and after opening the Terminal app again,

now shows something like this:

Whatever you do, when opening Terminal and running java -version, you should see something like this, with a version of at least 1.6.x

sudo is a program for Unix-like operating systems, allowing you to run programs with the security

privileges of another user (normally the superuser, or root). Since we are creating directories, outside of your home folder, administrator right are required. I.e., when executing sudo you

will be asked to enter your password; and your Mac User account needs to be an ‘Admin’ account.

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

I picked the tar.gz in Binary Distributions / Core section.

~/Downloads/apache-tomcat-7.0.47

Open to Terminal app to move the unarchived distribution to /usr/local

<code>sudo mkdir -p /usr/local</code>

<code>sudo mv ~/Downloads/apache-tomcat-7.0.47 /usr/local</code>

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 (after removing the old link, you might have from installing a previous version):

<code>sudo rm -f /Library/Tomcat sudo ln -s /usr/local/apache-tomcat-7.0.47 /Library/Tomcat</code>

Change ownership of the /Library/Tomcat folder hierarchy:

<code>sudo chown -R &lt;your_username&gt; /Library/Tomcat</code>

Make all scripts executable:

<code>sudo chmod +x /Library/Tomcat/bin/*.sh</code>

<a target="_blank" href="http://wolfpaulus.com/wp-content/uploads/2010/06/tomcat2.png"></a>

Instead of using the start and stop scripts, like so:

<code>Last login: Sun Aug 14 15:20:38 on ttys000 wpbookpro:~ wolf$ /Library/Tomcat/bin/startup.sh Using CATALINA_BASE: /Library/Tomcat Using CATALINA_HOME: /Library/Tomcat Using CATALINA_TMPDIR: /Library/Tomcat/temp Using JRE_HOME: /Library/Java/Home Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar wpbookpro:~ wolf$ /Library/Tomcat/bin/shutdown.sh Using CATALINA_BASE: /Library/Tomcat Using CATALINA_HOME: /Library/Tomcat Using CATALINA_TMPDIR: /Library/Tomcat/temp Using JRE_HOME: /Library/Java/Home Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar wpbookpro:~ wolf$</code>

<a target="_blank" href="http://wolfpaulus.com/wp-content/uploads/2010/06/tcontroller.png"></a>