Linux下Apache2+Tomcat5.0整合

上一篇 / 下一篇  2009-08-31 12:32:39 / 個人分類:Linux

#############################################

服務器已有安裝有Tomcat5.0和JDK1.4.2

Tomcat5.0目錄:/home/oracle/tomcat

JDK 1.4.2目錄:/home/oracle/j2sdk1.4.2_07

Tomcat5.0和JDK1.42安裝步驟略

#############################################

安裝Apache2.0.59至/home/oracle/apache

下載httpd-2.0.59.tar.gz上傳至/home/oracle

cd /home/oracle

tar -zxvf httpd-2.0.59.tar.gz

cd httpd-2.0.59

#配置(prefix是安裝路徑,enable-mods-shared=all表示編譯配置所有so文件)

./configure --prefix=/home/oracle/apache --enable-mods-shared=all

make

make install

#配置httpd.conf

vi /home/oracle/apache/conf/httpd.conf

ServerName配置為127.0.0.1,服務器IP或域名

DirectoryIndex中添加index.htm index.jsp

DefaultLanguage設置為zh-CN

cd /home/oracle/apache/bin

./apachectl start

打開http://127.0.0.1/看見"安裝Apache的測試頁面"說明Apache已經安裝成功

如果出現"403 Forbidden錯誤"(而且httpd.conf未設置不允許訪問),解決方法如下:

不但要將WEB目錄設置為可讀,還要將WEB目錄的所有父級目錄設置為至少可檢索

(參考官方FAQ:http://httpd.apache.org/docs/1.3/misc/FAQ.html#forbidden)

chmod x /home

chmod x /home/oracle

chmod x /home/oracle/apache

chmod 777 -R /home/oracle/apache/htdocs

################################################

編譯和設置mod_jk2

在http://archive.apache.org/dist/jakarta/tomcat-connectors/jk2/中

下載jakarta-tomcat-connectors-jk2-src-current.tar.gz,放至/home/oracle

tar zxvf jakarta-tomcat-connectors-jk2-src-current.tar.gz

cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2

./buildconf.sh

./configure --with-apxs2=/home/oracle/apache/bin/apxs --with-java-home=/home/oracle/j2sdk1.4.2_07

make jk2-build-apxs

cd server/apache2

make -f Makefile.apxs install

成功執行完這幾步驟之後,mod_jk2已經裝好,接下來是配置階段。

在/home/oracle/apache/conf目錄下建立workers2.properties文件,內容如下

#---- worker2.properties

[logger.apache2]

level=DEBUG

# Shared memory handling. Needs to be set.

[shm]

file=/home/oracle/apache/logs/shm.file

size=1048576

# Example socket channel, explicitly set port and host.

[channel.socket:localhost:8009]

tomcatId=localhost:8009

port=8009

host=127.0.0.1

# define the worker

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

#[status:status]

# Uri mapping

#[uri:/jkstatus/*]

#group=status:status

#[uri:/jsp-examples/*]

#group=ajp13:localhost:8009

#[uri:/servlets-examples/*]

#group=ajp13:localhost:8009

#[uri:/javaapp/*]

#group=ajp13:localhost:8009

#[uri:www.home.net/*.jsp]

#worker=ajp13:localhost:8009

#[uri:10.0.0.10/*]

#worker=ajp13:localhost:8009

#[uri:/*.do]

#worker=ajp13:localhost:8009

[uri:/servlet/*]

worker=ajp13:localhost:8009

[uri:/*.jsp]

worker=ajp13:localhost:8009

#---- end of workers2.properties

然後在httpd.conf中添加虛擬目錄

NameVirtualHost *

<VirtualHost *>

ServerAdmin 123@126.com

DocumentRoot /usr/website/123/webapps/ROOT

ServerName www.123.com

ErrorLog logs/123-error_log

CustomLog logs/123-access_log common

ErrorDocument 404 /error/404.html

ErrorDocument 401 /error/401.html

</VirtualHost>

################################################

配置Tomcat中的conf/server.xml文件

更改Tomcat端口為8080,避免與apache衝突

分別在<Connector port="8080"和<Connector port="8009"中添加URIEncoding="GBK",解決中文亂碼

添加與Apache虛擬主機對應的Tomcat虛擬主機

<Host name= www.123.com debug="0" appBase="/usr/website/123/webapps"

unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" > </Host>

################################################

至此,Linux下Apache2 Tomcat5整合成功!

日本奶粉婚紗攝影相約在南山的喝奶茶,因搬屋很快要成立公司,需要置辦一些辦公室傢俱。打算去佰鳴幫忙,卻在28KC遇到迷你倉風雪新娘化妝,還有物理治療也在搬寫字樓

TAG: Linux LINUX Apache2 Tomcat5 整合

 

評分:0

我來說兩句

顯示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

關於作者

網絡推薦

Real Time Web Analytics