伺服器已有安裝有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目錄的所有父級目錄設置為至少可檢索
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 *
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
配置Tomcat中的conf/server.xml文件
更改Tomcat埠為8080,避免與apache衝突
分別在
添加與Apache虛擬主機對應的Tomcat虛擬主機
unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" >
至此,Linux下Apache2+Tomcat5整合成功!
[火星人
]
Linux下Apache2+Tomcat5.0整合已經有393次圍觀
http://coctec.com/docs/linux/show-post-203482.html