Solaris 9(intel x86)下從源代碼安裝Tomcat 5實戰記錄
發表于:2007-06-08來源:作者:點擊數:
標簽:
I.[b:1c511aa29d]從源碼安裝Tomcat5[/b:1c511aa29d] 1.JDK安裝及設定 (1)使用Solaris9自帶的JDK [code:1:1c511aa29d] #java-version javaversion1.4.1_02a JavaTM2RuntimeEnvironment,StandardEditionbuild1.4.1_02a-b01 JavaHotSpotTMClientVMbuild1.4.1_02
I.[b:1c511aa29d]從源碼安裝Tomcat 5[/b:1c511aa29d]
1.JDK安裝及設定
(1)使用Solaris 9自帶的JDK
[code:1:1c511aa29d]
# java -version
java version "1.4.1_02a"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02a-b01)
Java HotSpot(TM) Client VM (build 1.4.1_02a-b01, mixed mode)
[/code:1:1c511aa29d]
(2)修改/etc/profile,加入JAVA_HOME環境變量
[code:1:1c511aa29d]
JAVA_HOME=/usr/java
export JAVA_HOME
[/code:1:1c511aa29d]
2.[b:1c511aa29d]安裝Apache Ant[/b:1c511aa29d]
(1)從[ur]http://ant.apache.org/bindownload.cgi[/url]下載ant的二進制包 apache-ant-1.6.1-bin.tar.gz
[code:1:1c511aa29d]
# gunzip < apache-ant-1.6.1-bin.tar.gz | tar xvf -
# mv apache-ant-1.6.1 /usr
# cd /usr
# ln -s apache-ant-1.6.1 ant
[/code:1:1c511aa29d]
(2)修改環境變量
[code:1:1c511aa29d]
ANT_HOME=/usr/ant
export ANT_HOME
PATH=$PATH:$ANT_HOME/bin
export PATH
[/code:1:1c511aa29d]
3.[b:1c511aa29d]編譯Tomcat[/b:1c511aa29d]
(1)從[url]http://jakarta.apache.org/tomcat/tomcat-5.0-doc/build.xml[/url]下載編譯所需的build.xml
建一個目錄用來放下載的Tomcat源代碼,把那個build.xml也放在這,為了方便,稱這個目錄為${tomcat.source}.
運行ant之前,需要知道ant先從Apache的
CVS服務器中把Tomcat 5的源碼checkout出來(需要先安裝
cvs),并且要下載一些編譯時需要的lib文件,
這些lib文件默認是放在/usr/share/java下。如果/usr/share/java這個目錄不存在,可以先創建,也可以在build.properties
文件中指定(如果需要
網絡代理的話,也需要在${tomcat.source}下建一個build.properties文件)。
build.properties的內容如下
[code:1:1c511aa29d]
# ----- Proxy setup -----
# Uncomment if using a proxy server
#proxy.host=proxy.domain
#proxy.port=8080
#proxy.use=on
# ----- Default Base Path for Dependent Packages -----
# Replace this path with the directory path where dependencies binaries
# should be downloaded
base.path=/usr/share/java
[/code:1:1c511aa29d]
(2)運行ant,編譯
[code:1:1c511aa29d]
# cd ${tomcat.source}
# ant
[/code:1:1c511aa29d]
等ant成功運行后,在${tomcat.source}/jakarta-tomcat-5/build目錄下可以找到編譯好的Tomcat
4.[b:1c511aa29d]啟動Tomcat[/b:1c511aa29d]
(1)添加環境變量
[code:1:1c511aa29d]
CATALINA_HOME=${tomcat.source}/jakarta-tomcat-5/build
export CATALINA_HOME
[/code:1:1c511aa29d]
(2)修改$CATALINA_HOME/conf/tomcat-users.xml,添加一管理用戶
[code:1:1c511aa29d]
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="password" roles="admin,manager"/>
[/code:1:1c511aa29d]
(3)運行$CATALINA_HOME/bin/startup.sh啟動Tomcat
訪問http://server-ip:8080/manager/status
5.[size=21:1c511aa29d][color=red:1c511aa29d][b:1c511aa29d]Run Tomcat as a daemon[/b:1c511aa29d][/color:1c511aa29d][/size:1c511aa29d]
(1)首先編譯jsvc,需要先安裝g
clearcase/" target="_blank" >cc、autoconf、automake和m4
[code:1:1c511aa29d]
# cd ${tomcat.source}/jakarta-commons/daemon/src/native/unix
# chmod 744 support/buildconf.sh
# support/buildconf.sh
# ./configure
# make
[/code:1:1c511aa29d]
執行buildconf.sh可能會出現這樣的錯誤
[code:1:1c511aa29d]
autoconf: /usr/local/bi/autom4te: not found
[/code:1:1c511aa29d]
這是因為autom4te腳本找不到perl解釋器。解決辦法是
[code:1:1c511aa29d]
# ln -s /usr/bin/perl /usr/local/bin/perl
[/code:1:1c511aa29d]
make時可能會報
[code:1:1c511aa29d]
make[1]:ar:Command not found
[/code:1:1c511aa29d]
這個需要把/usr/ccs/bin加到PATH環境變量中
編譯成功后,就會在${tomcat.source}/jakarta-commons/daemon/src/native/unix目錄下生成jsvc
(2)在${tomcat.source}/jakarta-commons/daemon/src/native/unix/native下有一個Tomcat5.sh可以用作啟動腳本
[code:1:1c511aa29d]
# cp ${tomcat.source}/jakarta-commons/daemon/src/native/unix/native/Tomcat5.sh /etc/init.d/tomcat
# cd /etc/rc2.d
# ln ../init.d/tomcat S99tomcat
# cd ../rc0.d
# ln ../init.d/tomcat K03tomcat
[/code:1:1c511aa29d]
(3)添加運行tomcat的用戶
[code:1:1c511aa29d]
# groupadd tomcat
# useradd -g tomcat -d ${tomcat.source} tomcat
# chown -R tomcat:tomcat ${tomcat.source}
[/code:1:1c511aa29d]
修改/etc/init.d/tomcat,主要是這幾個變量
[code:1:1c511aa29d]
JAVA_HOME=/usr/java
CATALINA_HOME=${tomcat.source}/jakarta-tomcat-5/build
DAEMON_HOME=${tomcat.source}/jakarta-commons/daemon
TOMCAT_USER=tomcat
[/code:1:1c511aa29d]
用這個腳本啟動和關閉tomcat
[code:1:1c511aa29d]
# /etc/init.d/tomcat start
# /etc/init.d/tomcat stop
[/code:1:1c511aa29d]
(4)重新啟動機器,一切正常的話,tomcat就運行在后臺了
[code:1:1c511aa29d]
# ps -ef|grep tomcat |grep -v grep
tomcat 337 331 0 13:11:55 ? 0:29 /export/home/tomcat5/jakarta-commons/daemon/src/native/unix/jsvc -user tomcat -
root 331 1 0 13:11:55 ? 0:00 /export/home/tomcat5/jakarta-commons/daemon/src/native/unix/jsvc -user tomcat -
[/code:1:1c511aa29d]
C.Arthur 回復于:2004-02-14 15:41:21
|
不錯,支持一下
|
wolfg 回復于:2004-02-14 15:42:35
|
多謝版主
|
C.Arthur 回復于:2004-02-14 15:44:04
|
這是應該做的,寫的很好哇,很清楚,格式也好:)
|
wolfg 回復于:2004-02-14 15:45:19
|
我還要繼續努力,下一步準備試一試jakarta-tomcat-connector
|
C.Arthur 回復于:2004-02-14 16:22:08
|
想法不錯,其實你可以弄一個wolfg系列的軟件調試文檔
|
wolfg 回復于:2004-02-14 16:36:04
|
[quote:1d9c638b20="C.Arthur"]想法不錯,其實你可以弄一個wolfg系列的軟件調試文檔[/quote:1d9c638b20]呵呵,是啊
|
多麗絲 回復于:2004-02-14 18:32:23
|
樓主辛苦啦,寫的不錯哦!
|
wolfg 回復于:2004-02-19 16:09:12
|
[quote:971371f582="wolfg"]我還要繼續努力,下一步準備試一試jakarta-tomcat-connector[/quote:971371f582]
請看[b:971371f582][url=http://bbs.chinaunix.net/forum/6/20040219/263220.html]用mod_jk2整合Tomcat 5與Apache 2.0.48(TCP/IP Socket方式) [/url][/b:971371f582]
|
wolfg 回復于:2004-02-20 12:38:12
|
請看續二[b:e4802b081c][url=http://bbs.chinaunix.net/forum/6/20040220/263825.html]Apache + Tomcat + Load Balancing [/url][/b:e4802b081c]
|
pengtao_hlp 回復于:2004-02-20 14:18:57
|
tomcat是什么東西呀???
|
wolfg 回復于:2004-02-20 14:34:05
|
[quote:cca3e3bb93="pengtao_hlp"]tomcat是什么東西呀???[/quote:cca3e3bb93]
Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies.
|
blessfish 回復于:2004-04-11 23:53:37
|
請問第三個步驟所說的拷貝一部分lib的文件到source目錄下,應該是哪些目錄哪?我編譯的時候報告“Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher”,應該是差這些文件,但是具體是哪些哪?請告知,謝謝!
|
原文轉自:http://www.anti-gravitydesign.com