歡迎您光臨本站 註冊首頁

Fedora8下JDK+apache+tomcat安裝整合

←手機掃碼閱讀     火星人 @ 2014-03-25 , reply:0

安裝完畢Fedora8后,發現其自帶的apache httpd 和tomcat版本略低且配置上並不是標準方式,決定卸載這兩個服務,自己動手安裝最新的版本;另外更新一下JDK

卸載:

卸載非常容易,在Fedora8的圖形界面環境下,打開程序菜單,找到更新程序項,點擊后出現對話框,將列表中httpd和tomcat服務前的鉤去掉,確定,卸載完畢;

更新JDK

1.從www.sun.com下載最新的JDK版本,我下載的是jdk-6u5-linux-i586.bin

2.安裝 ./ jdk-1_5_0_06-linux-i586.bin

3.設置環境變數

[[email protected] local]# vi /etc/profile
在該文件的末尾加上下面兩行
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

安裝apache

apache的安裝也很簡單

1.從www.apache.org 下載最新的http server版本,我下載的是httpd-2.2.8.tar.gz;

2.進行解壓

3.配置安裝參數:[[email protected] httpd-2.2.8]# ./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=all ;載入全部模塊,之後可在配置文件中禁用不需要的模塊

4.編譯 make 安裝 make install

5.啟動 [[email protected] bin]# ./apachectl start 測試 http://127.0.0.1 頁面出現 It Works! 安裝成功!

安裝tomcat

同樣簡單

1. 從www.apache.org 下載最新的apache tomcat版本,我下載的是 apache-tomcat-6.0.16-deployer.tar.gz;

2. 進行解壓

3. 設置環境變數CATALINA_HOME,並驗證
[[email protected] local]# vi /etc/profile
在文件最後加入如下一行
export CATALINA_HOME=/usr/local/tomcat
保存退出

4.啟動 測試 訪問127.0.0.1:8080 出現大貓,安裝成功!

整合apache+tomcat

整合過程稍費周折,但也還不是太麻煩

1.從www.apache.org下載轉發功能模塊tomcat-connectors的最新版本,我下載的是tomcat-connectors-1.2.26-src.tar.gz;

2.進行解壓

3.到解壓后的native目錄進行安裝配置,指定apache目錄tomcat目錄和JDK目錄位置, [[email protected] native]#./configure --with-apxs=/usr/local/apache/bin/apxs --with-tomcat=/usr/local/tomcat --with-java-home=/usr/java/jdk --with-jni

4.運行配置命令后,提示我zlib包找不到。。。只好去下載安裝zlib ,也較為簡單,不再累述;

5.配置正確完成後,進行編譯 make

6.編譯結束後到native下的apache-2.0目錄下看看,應該生成了一個mod_jk.so文件,這就是轉發模塊,將其拷貝至apache安裝目錄下的modules目錄

7.修改apache/conf目錄下的httpd.conf文件,在LoadModule的部分添加如下內容,使apache載入轉發模塊:

LoadModule jk_module modules/mod_jk.so

# Declare the module for (remove this line on Apache 2.x)
#AddModule mod_jk.c
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile conf/workers.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
#JkLogFile logs/mod_jk.log
# JkLogFile "|/opt/webserver/apache2/bin/rotatelogs /opt/logs/mod_log/mod%Y_%m_%d.log 86400 480"
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /examples to worker named worker1 (ajp13)
#JkMount /* balancer
JkMountFile conf/uriworkermap.properties
JkShmFile logs/jk.shm


SetHandler server-status
JkMount status
Order deny,allow
Deny from all
Allow from all




8.在apache/conf目錄下創建兩個文件 workers.properties 和 uriworkermap.properties;

workers.properties 是轉發模塊的工作單定義轉發主機和監聽埠等內容,見下:
#
# workers.properties
#

# list the workers by name

worker.list=localhost,status

#workers
# ------------------------
# First tomcat server
# ------------------------
worker.localhost.port=8009
worker.localhost.host=127.0.0.1
worker.localhost.type=ajp13
#worker.localhost.socket_timeout=300
worker.localhost.lbfactor=1

# Status worker for managing load balancer
worker.status.type=status

#
# END workers.properties
#


uriworkermap.properties是定義工作單里每個工作項的轉發規則的,見下:
# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
#/jmx-console=loadbalancer
#/jmx-console/*=loadbalancer

/examples/*=localhost
/jkstatus/=status

至此,整合操作全部完成,重啟tomcat和apache,就可以通過http://127.0.0.1/examples 訪問到tomcat的目錄去了

另外要注意的是,轉發模塊在apache版本一致的情況下是可通用的,但如果apache版本不一致,就只能自己進行編譯了。

[火星人 ] Fedora8下JDK+apache+tomcat安裝整合已經有410次圍觀

http://coctec.com/docs/linux/show-post-166761.html