1. 程式人生 > >實踐補充 Installing Tomcat 7.0.x on OS X

實踐補充 Installing Tomcat 7.0.x on OS X

ocp npr epc cgi security hssf xca 之前 epub

我的 Mac 下是1.6的 SDK,下載 Tomcat 8.0 執行後,訪問 http://127.0.0.1:8080 並無反應,並且關閉腳本會報錯 :

Unsupported major.minor version 51.0

看來安裝 Tomcat 8.0 須要至少 JDK 1.7 或 JDK 1.8 才行,只是我的 Mac 上沒有提示。我也就不更新了。


故又一次下載 Tomcat 6.0 ,按例如以下操作。一切正常。並能正常訪問 8080 port打開頁面。

再次下載 Tomcat 7.0 ,按例如以下操作反復,一切正常,並能正常訪問 8080 port打開頁面。


只是有一點,須要註意,就是 link 生成的 /Library/Tomcat 須要先 unlink:

sudo unlink /Library/Tomcat


1、mv 下載並解壓出來的Tomcat文件夾 /usr/local

這一步,我是先輸入個 mv,然後從 Finder 中把文件夾拖到 console 中,自己主動顯示路徑串,然後再輸入 /L 然後按 Tab 鍵自己主動補齊 Library ,假設你的文件夾中存在多個 L 開頭的文件或文件夾,那就再多輸幾個字符,確保唯一就能夠自己主動補全了。再輸入 /T 。繼續按 Tab 鍵自己主動補全

2、sudo unlink /Library/Tomcat

取消之前安裝時創建的 /Library/Tomcat 鏈接

3、sudo ln -s /usr/local/apache-tomcat-7.0.56

/ /Library/Tomcat

4、sudo chown -R 當前用戶 /Library/Tomcat

5、sudo chmod +x /Library/Tomcat/bin/*.sh

將 Tomcat 文件夾下的 .sh 腳本改動為可執行

6、/Library/Tomcat/bin/startup.sh

啟動 Tomcat ,當前鏈接到哪個版本號的 Tomcat 。啟動的就是哪個版本號的 Tomcat

7、http://127.0.0.1:8080

使用瀏覽器打開這個地址port。能正常顯示 Tomcat 的歡迎頁面。就表示布署 Tomcat 成功

8、/Library/Tomcat/bin/shutdown.sh

關閉 Tomcat 服務

9、下載並安裝 Tomcat Controller。UI 啟停 Tomcat

註意。默認的 Tomcat Home Directory 是指向 /usr/local/tomcat,能夠在這裏更改成特定版本號的 Tomcat。也能夠按下圖指定。然後通過上面的鏈接來更改當前的 Tomcat 版本號。

感覺前者更方便些。也免於創建鏈接了。

技術分享


Tomcat 6.0 下載鏈接:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-6/v6.0.43/bin/apache-tomcat-6.0.43.zip (2015-02-10 更新)

Tomcat 7.0 下載鏈接:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.59/bin/apache-tomcat-7.0.59.zip (2015-02-10 更新)

Tomcat 8.0 下載鏈接:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.0.18/bin/apache-tomcat-8.0.18.zip

Tomcat Controller 下載鏈接:http://www.activata.co.uk/downloads_files/TomcatController_1_2.dmg.zip



接下來,研究 Spring Mvc 框架,以及 mybatis 操作 mysql 數據庫,並由 Spring 管理數據庫連接事務。

逐步研究步驟:

1、Spring Mvc 框架 + SQLHelper 讀寫 mysql 數據庫;

據說 Spring Mvc 要比 Structs2 效率高一些,並且如今在招聘站點上搜相似的招聘。基本都是 Spring 的 Mvc 框架,

別理解錯了。上招聘站點一不是為找工作。二不是為招人。招聘站點是技術走向的風向標。在一段時間內的統計結果。非常有代表性。

2、mybatis 操作 mysql

3、Spring 管控 mybatis 數據庫連接池

4、三者整合研究


同一樣技術,不同的人有不同的研究過程和理解。但結果都是一樣的,能把它們用起來。

不一定真正用得到。但至少能知道別人做得對不正確,問題出在哪兒。這就夠了。






_____________________________________________________

Installing Tomcat 7.0.x on OS X

by Wolf Paulus | Dec 14, 2013 | Mac OS X | 281 comments


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.


On 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.

Prerequisite: Java

On 10.9 (Mavericks), Apple changed this once again, now sending you to Oracle’s Java SE web page, where you can download the JDK, (currently 7 jdk-7u45-macosx-x64.dmg). While at Oracle, I usually also download the Java SE Development Kit 7 Documentation, allowing me to stay away from their site for many months.



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

java -version

now shows something like this:

java version "1.7.0_45"

Java(TM) SE Runtime Environment (build 1.7.0_45-b18)

Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

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.

Installing Tomcat

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.47.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
  2. Opening/unarchiving the archive will create a folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
  3. ~/Downloads/apache-tomcat-7.0.47
  4. Open to Terminal app to move the unarchived distribution to /usr/local
  5. sudo mkdir -p /usr/local
  6. sudo mv ~/Downloads/apache-tomcat-7.0.47 /usr/local
  7. 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):
  8. sudo rm -f /Library/Tomcat
    sudo ln -s /usr/local/apache-tomcat-7.0.47 /Library/Tomcat
  9. Change ownership of the /Library/Tomcat folder hierarchy:
  10. sudo chown -R <your_username> /Library/Tomcat
  11. Make all scripts executable:
  12. sudo chmod +x /Library/Tomcat/bin/*.sh





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

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$

you may also want to check out Activata’s Tomcat Controller, a tiny freeware app, providing a UI to quickly start/stop Tomcat. It may not say so, but Tomcat Controller works on OS X 10.8 and 10.9 just fine.




Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page: http://localhost:8080

.entry-content You can start editing here.


實踐補充 Installing Tomcat 7.0.x on OS X