0

CentOS5.3下Apache+tomcat+jk整合

已有 186 阅读此文人 - - Linux,系统管理 -

CentOS5.3下Apache+tomcat+jk整合

系统环境:
CentOS5.3
httpd-2.2.11
apache-tomcat-6.0.18.t tomcat-connectors-1.2.28
jdk-6u10-rc-bin-b28-linux-i586-21_jul_2008-rpm.bin
系统关闭不需要的服务:
#vi init.sh
#disable ipv6
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf
/sbin/chkconfig --level 35 ip6tables off
echo "ipv6 is disabled!"
#disable selinux
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
echo "selinux is disabled,you must reboot!"
#vim
sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
echo 'syntax on' > /root/.vimrc
#zh_cn
sed -i -e 's/^LANG=.*/LANG="zh_CN.GB18030"/' /etc/sysconfig/i18n
#tunoff services
for i in `ls /etc/rc3.d/S*`
do
CURSRV=`echo $i|cut -c 15-`

echo $CURSRV
case $CURSRV in
crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld )
echo "Base services, Skip!"
;;
*)
echo "change $CURSRV to off"
chkconfig --level 235 $CURSRV off
service $CURSRV stop
;;
esac
done
二、安装系统必须的包
#yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
三、需要的软件:
http://apache.mirror.phpchina.com/httpd/httpd-2.2.11.tar.gz
http://www.java.net/download/jdk6/6u10/promoted/b28/binaries/jdk-6u10-rc-bin-b28-linux-i586-21_jul_2008-rpm.bin
http://apache.mirror.phpchina.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-connectors/jk/source/jk-1.2.28/tomcat-connectors-1.2.28-src.tar.gz

安装apache
#vi init.sh
./configure \
"--prefix=/usr/local/apache2" \
"--with-included-apr" \
"--enable-so" \
"--enable-deflate=shared" \
"--enable-expires=shared" \
"--enable-rewrite=shared" \
"--enable-static-support" \
"--disable-userdir"
make
make install
echo '/usr/local/apache2/bin/httpd -k start ' >> /etc/rc.local
安装jdk
#chmod u+x jdk-6u10-rc-bin-b28-linux-i586-21_jul_2008-rpm.bin
#./jdk-6u10-rc-bin-b28-linux-i586-21_jul_2008-rpm.bin
一路回车安装就会自动安装好
安装tomcat
#tar zvxf apache-tomcat-6.0.18.tar.gz
#mv apache-tomcat-6.0.18 tomcat
六、安装jk
#tar zvxf tomcat-connectors-1.2.28-src.tar.gz
#cd tomcat-connectors-1.2.28-src/native/
#./configure --with-apxs=/usr/local/apache2/bin/apxs && make && make install
到apache的modules下面看看有没有mod_jk.so模块
配置apache支持jk模块
#vi /usr/local/apache2/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so
……
Include conf/extra/mod_jk.conf
#vi /usr/local/apache2/conf/extra/mod_jk.conf
JkWorkersFile conf/extra/workers.properties
JkLogFile logs/mod_jk.log
JkShmFile logs/jk-runtime-status
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"

#Sample JkMounts. Replace these with the paths you would
#like to mount from your JSP server.
#syntax: JkMount ${URL_DIR}/*.jsp worker_name

JkMount /images/avatar/* worker1
JkMount /*.jsp worker1
JkMount /*.page worker1
JkMount /*.cic worker1
JkMount /func/* worker1
JkMount /assets/* worker1
JkMount /remote/* worker1
JkMount /services/* worker1
JkMount /homebase/* worker1
JkMount /skin/* worker1
JkMount /error/* worker1
JkMount /lib/* worker1
JkMount /protected/* worker1
JkMount /rounded/* worker1
JkMount /FormOverLogin* worker1
JkMount /fckeditor/editor/filemanager/connectors/* worker1
JkMount /upload/image/* worker1
# vi /usr/local/apache2/conf/extra/workers.properties
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.woker1.lbfactor=1
修改tomcat跟apache知道让web指向同一个目录
#vi /usr/local/tomcat/conf/server.xml


#vi /usr/local/apache2/conf/extra/httpd-vhost.conf

ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/data/www/wwwroot"
ServerName www.test.com
#ServerAlias test.com
#ErrorLog "logs/www.test.com-error_log"
#CustomLog "logs/www.test.com-access_log" common

启动测试
#/usr/local/apache2/bin/apachectl start
#sh /usr/local/tomcat/bin/startup.sh
#vi /data/www/wwwroot/index.html
html页面测试
#vi /data/www/wwwroot/index.jsp
<%out.print("jsp页面测试");%>

Html:

Jsp:

Jdk1.5下载地址:
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-1_5_0_19-linux-i586.bin?BundledLineItemUUID=gZFIBe.mKjwAAAEi_2UKr78a&OrderID=zTBIBe.mUh8AAAEi42UKr78a&ProductID=zaJIBe.pkVcAAAEh_r8P5zJQ&FileName=/jdk-1_5_0_19-linux-i586.bin

http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-1_5_0_19-linux-i586-rpm.bin?BundledLineItemUUID=X3FIBe.m2JgAAAEi9WUKr78a&OrderID=zTBIBe.mUh8AAAEi42UKr78a&ProductID=zaJIBe.pkVcAAAEh_r8P5zJQ&FileName=/jdk-1_5_0_19-linux-i586-rpm.bin

期待你一针见血的评论,Come on!

不用想啦,马上 "登录"  发表自已的想法.