主頁 > 知識(shí)庫 > RHEL5 Apache+Tomcat整合,同時(shí)支持jsp與php

RHEL5 Apache+Tomcat整合,同時(shí)支持jsp與php

熱門標(biāo)簽:沈陽藝匯通地圖標(biāo)注 智能電話機(jī)器人金融 騰訊美術(shù)館地圖標(biāo)注 孝感營(yíng)銷電銷機(jī)器人源碼 ai電銷機(jī)器人自動(dòng)篩選意向客戶 思茅地圖標(biāo)注app 鄭州智能外呼系統(tǒng)招商 AI電銷機(jī)器人PHP源碼 打電話機(jī)器人是什么軟件

配置環(huán)境:
OS: RHEL5 with kernel 2.6.18-8.1.1.el5
httpd-2.2.3-6.el5.i386.rpm
apache-tomcat-6.0.14.tar.gz
jdk-6u3-linux-i586.bin
mod_jk-1.2.23-apache-2.2.x-linux-i686.so
官方宣稱mod_jk-1.2.26-httpd-2.2.6.so支持Apache 2.2.x及2.2.6以后的版本,但經(jīng)實(shí)驗(yàn),1.2.26的mod_jk在RHEL5中會(huì)報(bào)錯(cuò)。

下載地址:
http://java.sun.com/javase/downloads/index.jsp
http://www.apache.org/dist/tomcat/tomcat-connectors
http://apache.mirror.phpchina.com/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.23/

一、安裝配置jdk及tomcat
1、安裝jdk及tomcat
[root@wardking ~]# tar zxvf apache-tomcat-6.0.14.tar.gz -C /usr/local/
[root@wardking ~]# mv jdk-6u3-linux-i586.bin /usr/local/
[root@wardking ~]# cd /usr/local
[root@wardking local]# chmod a+x jdk-6u3-linux-i586.bin
[root@wardking local]# ./jdk-6u3-linux-i586.bin

2、配置環(huán)境變量
[root@wardking ~]# ln -sf /usr/local/apache-tomcat-6.0.14 /usr/local/tomcat
[root@wardking ~]# ln -sf /usr/local/jdk1.6.0_03 /usr/local/jdk6
[root@wardking ~]# ln -sf /usr/local/jdk6/bin/java /usr/bin/
[root@wardking ~]# ln -sf /usr/local/tomcat/bin/startup.sh /usr/bin/tomcat-up
[root@wardking ~]# ln -sf /usr/local/tomcat/bin/shutdown.sh /usr/bin/tomcat-down
添加一個(gè)名為“michael”的管理員用戶
[root@wardking ~]# vi /usr/local/tomcat/conf/tomcat-users.xml
user username="michael" password="123456" roles="manager,admin"/>
設(shè)置環(huán)境變量
[root@wardking ~]# vi /etc/profile
JAVA_HOME=/usr/local/jdk6
CATALINA_HOME=/usr/local/tomcat
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/servlet-api.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CATALINA_HOME CLASSPATH PATH
[root@wardking ~]# source /etc/profile
3、測(cè)試tomcat服務(wù)
[root@wardking ~]# /usr/bin/tomcat-up
或者直接執(zhí)行
/usr/local/tomcat/bin/startup.sh
檢查tomcat是否啟動(dòng)
[root@wardking ~]# netstat -anp | grep 8080
在瀏覽器里訪問http://localhost:8080/,可以看到tomcat的網(wǎng)頁界面,并可以使用
用戶“michael”登陸管理
停止tomcat服務(wù)
[root@wardking ~]# tomcat-down
二、連接tomcat到apache
1、安裝mod_jk模塊
[root@wardking ~]# cp mod_jk-1.2.23-apache-2.2.x-linux-i686.so /etc/httpd/modules/
2、修改apache配置文件
[root@wardking ~]# vi /etc/httpd/conf.d/mod_jk.conf
LoadModule jk_module modules/mod_jk-1.2.23-apache-2.2.x-linux-i686.so
JkWorkersFile "/etc/httpd/conf/workers.properties"
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile "/var/log/httpd/mod_jk.log"
JkLogLevel info
JkMount /*/servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
AddType application/x-jsp .jsp
3、添加tomcat配置文件
[root@wardking ~]# vi /etc/httpd/conf/workers.properties
[shm]
file=/etc/httpd/logs/shm.file
size=1048576
[channel.socket:localhost:8009]
tomcatId=localhost:8009
[uri:/jsp-examples/*]
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/jdk6
ps=\
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
4、設(shè)置tomcat主目錄
[root@wardking ~]# vi /usr/local/tomcat/conf/server.xml
       Host name="localhost"   appBase="/var/www/html/"
             unpackWARs="true" autoDeploy="true"
             xmlValidation="false" xmlNamespaceAware="false">
         Context path="" docBase="" debug="0"/>
5、確認(rèn)apache、tomcat啟動(dòng)

[root@wardking ~]# httpd -t
[root@wardking ~]# service httpd restart
[root@wardking ~]# /usr/bin/tomcat-up
6、分別測(cè)試訪問php和jsp網(wǎng)頁
[root@wardking ~]# vi /var/www/html/showtime.jsp
%@page language="java" import="java.util.*"%>
Now Time is : % out.println(new Date()); %>
[root@wardking ~]# echo '?php phpinfo(); ?>' > phpinfo.php
在瀏覽器中訪問http://localhost/showtime.jsp,應(yīng)在網(wǎng)頁中顯示系統(tǒng)時(shí)間
訪問http://localhost/phpinfo.php,顯示php及服務(wù)器相關(guān)配置信息

另一種整合辦法,在httpd.conf中使用反向代理:
ProxyPass /images !
ProxyPass /icons !
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/

標(biāo)簽:張掖 淄博 江蘇 延安 和田 臨汾 甘孜

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《RHEL5 Apache+Tomcat整合,同時(shí)支持jsp與php》,本文關(guān)鍵詞  RHEL5,Apache+Tomcat,整合,同時(shí),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《RHEL5 Apache+Tomcat整合,同時(shí)支持jsp與php》相關(guān)的同類信息!
  • 本頁收集關(guān)于RHEL5 Apache+Tomcat整合,同時(shí)支持jsp與php的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章