︿
Top

1、前言

Jakarta TomcatSunApache 協力合作所開發出來 Java Servlet 及 Java Server Pages 平台,簡單說讓您的 Web Server (Apache) 成為能執行 JSP 的平台而 Jakarta Tomcat 也是目前在世界上使用最廣的 JSP 平台。






文章目錄

1、前言
2、實作環境
3、安裝及設定
          步驟1.安裝 linux base 套件
          步驟2.下載相關檔案及安裝 tomcat5 套件
          步驟3.啟動 tomcat5 服務
          步驟4.連結 tomcat 預設頁
4、參考





2、實作環境

  • FreeBSD 5.2-RELEASE
  • linux_base-7.1_7
  • jakarta-tomcat-5.0.25
  • JDK1.4.2
  • bsd-jdk14-patches-6.tar.gz
  • j2sdk-1_4_2-bin-scsl.zip
  • j2sdk-1_4_2-src-scsl.zip
  • j2sdk-1_4_2_05-linux-i586.bin





3、安裝及設定

步驟1.安裝 linux base 套件

切換至 Ports Tree 路徑安裝 linux base 套件。
cd /usr/ports/emulators/linux_base    //切換至安裝路徑
make install clean                      //安裝套件並清除暫存檔案

修改 /etc/rc.conf 以便開機時自動載入 linux.ko。
vi /etc/rc.conf        //修改 rc.conf
 linux_enable="YES"      //加入此行

修改完成後鍵入 kldstat 指令查看 linux.ko 是否載入至核心。
kldstat                //查看 linux.ko 是否載入至核心
 Id Refs Address Size Name
 3 1 0xc4794000 19000 linux.ko




步驟2.下載相關檔案及安裝 tomcat5 套件

切換至 Ports Tree 路徑安裝 tomcat5 套件。
cd /usr/ports/www/jakarta-tomcat5    //切換至安裝路徑
make install clean                     //安裝套件途中出現如下錯誤訊息
 ===> Configuring for jakarta-tomcat-5.0.25
 ===> Installing for jakarta-tomcat-5.0.25
 ===> jakarta-tomcat-5.0.25 depends on file: /usr/local/jdk1.4.2/bin/java - not found
 ===> Verifying install for /usr/local/jdk1.4.2/bin/java in /usr/ports/java/jdk14
 ===> jdk-1.4.2p6_4 :
 The source distribution exists on your system, but due to licensing  restrictions you still need to download thepatchset,  bsd-jdk14-patches-6.tar.gz, from
 http://www.eyesbeyond.com/freebsddom/java/jdk14.html.
 Please place the patchset in /usr/ports/distfiles.
 .*** Error code 1
 Stop in /usr/ports/java/jdk14.
 *** Error code 1
 Stop in /usr/ports/www/jakarta-tomcat5.

由上述訊息可知系統請您至下載 bsd-jdk14-patches-6.tar.gz ,並存放至 /usr/ports/distfiles 後再度執行 make install clean。
make install clean
 ===> Installing for jakarta-tomcat-5.0.25
 ===> jakarta-tomcat-5.0.25 depends on file: /usr/local/jdk1.4.2/bin/java - not found
 ===> Verifying install for /usr/local/jdk1.4.2/bin/java in /usr/ports/java/jdk14
 ===> jdk-1.4.2p6_4 :
 Because of licensing restrictions, you must fetch the source distribution
 manually. Please access http://www.sun.com/software/java2/download.html
 with a web browser and follow the "Download" link for the
 "Java(TM) SDK 1.4.2". You will be required to log in and register,
 but you can create an account on this page. After registration and
 accepting the Sun Community Source License, select "J2SESDK" and
 download the source file, j2sdk-1_4_2-bin-scsl.zip. Please place this file in/usr/ports/distfiles. .*** Error code 1 Stop in /usr/ports/java/jdk14. *** Error code 1 Stop in /usr/ports/www/jakarta-tomcat5.

由上述訊息可知系統請您至下載 j2sdk-1_4_2-bin-scsl.zip(需註冊資料才能下載),並存放至 /usr/ports/distfiles 後再度執行 make install clean。
make install clean
 ===> Installing for jakarta-tomcat-5.0.25
 ===> jakarta-tomcat-5.0.25 depends on file: /usr/local/jdk1.4.2/bin/java - not found
 ===> Verifying install for /usr/local/jdk1.4.2/bin/java in /usr/ports/java/jdk14
 ===> jdk-1.4.2p6_4 :
 Because of licensing restrictions, you must fetch the source distribution
 manually. Please access http://www.sun.com/software/java2/download.html
 with a web browser and follow the "Download" link for the
 "Java(TM) SDK 1.4.2". You will be required to log in and register,
 but you can create an account on this page. After registration and
 accepting the Sun Community Source License, select "J2SESDK" and
 download the source file, j2sdk-1_4_2-src-scsl.zip. Please place this file in
 /usr/ports/distfiles.
 .*** Error code 1
 Stop in /usr/ports/java/jdk14.
 *** Error code 1
 Stop in /usr/ports/www/jakarta-tomcat5.

由上述訊息可知系統請您至下載 j2sdk-1_4_2-src-scsl.zip (需註冊資料才能下載),並存放至 /usr/ports/distfiles 後再度執行 make install clean。
make install clean
 ===> Returning to build of jdk-1.4.2p6_4
 ===> jdk-1.4.2p6_4 depends on file: /usr/local/linux-sun-jdk1.4.2/bin/javac - not found
 ===> Verifying install for /usr/local/linux-sun-jdk1.4.2/bin/javac in /usr/ports/java/linux-sun-jdk14
 ===> linux-sun-jdk-1.4.2.05 You must manually fetch the J2SE SDK   self-extracting file for the Linux platform (j2sdk-1_4_2_05-linux-i586.bin)  from  http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=j2sdk-1.4.2_05-oth-JPR&SiteId=JSC&TransactionId=noreg,  place it in /usr/ports/distfiles and then run make again.
 *** Error code 1
 Stop in /usr/ports/java/linux-sun-jdk14.
 *** Error code 1
 Stop in /usr/ports/java/jdk14.
 *** Error code 1
 Stop in /usr/ports/www/jakarta-tomcat5.

由上述訊息可知系統請您至下載 j2sdk-1_4_2_05-linux-i586.bin (需註冊資料才能下載),並存放至 /usr/ports/distfiles 後再度執行 make install clean,安裝完成尾聲系統出現如下訊息告知您 Tomcat 的相關檔案安裝路徑、執行檔路徑及 Port Number。
make install clean
 ===> Patching for jakarta-tomcat-5.0.25
 Installation settings:
 Destination directory: /usr/local/jakarta-tomcat5.0
 Control program location: /usr/local/bin/tomcat50ctl
 Startup script location: /usr/local/etc/rc.d/020.jakarta-tomcat50.sh
 Location of JDK: /usr/local/linux-sun-jdk1.4.2
 Location of Java port: java/linux-sun-jdk14
 Running as (user/group): www/www
 HTTP port: 8180
 Shutdown listener port: 8005
 WARP port: 8008
 AJP 1.3 connector port: 8009
 Logfile stdout: /usr/local/jakarta-tomcat5.0/logs/stdout.log
 Logfile stderr: /usr/local/jakarta-tomcat5.0/logs/stderr.log
 Starting after install: NO
 Stop time-out: 5 sec.




步驟3.啟動 tomcat5 服務

鍵入如下指令啟動 Tomcat 服務 (請依個人喜好擇一即可)。
/usr/local/etc/rc.d/020.jakarta-tomcat50.sh start  //方法一
/usr/local/bin/tomcat50ctl start                     //方法二

檢查 Tomcat Process 是否運作。
ps auxwww|grep java           //查看執行序是否執行
 /usr/local/linux-sun-jdk1.4.2/bin/java -jar -Dcatalina.home=/usr/local/jakarta-tomcat5.0 bin/bootstrap.jar start

檢查 Tomcat 是否聆聽 Port Number。
sockstat |grep java           //查看相關 Port 是否為聆聽狀態
 www java 6299 11 tcp4 *:8180 *:*     




步驟4.連結 tomcat 預設頁

開啟如下 URL 連結至 Tomcat 預設頁面,若系統成功載入 Tomcat 的話將會看到如下 Tomcat Logo。
ex. http://www.weithenn.org:8180






4、參考

文章標籤: