一、所需软件包
OS:CentOS-5.4-i386
httpd-2.2.9.tar.gz
apache-tomcat-6.0.32.tar.gz
#wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz
jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
#wget http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/source/jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
jdk-1_5_0_06-linux-i586.bin
二、apache安装
1、编译环境搭建
- # for i in gcc gcc-c flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel ; do yum install -y $i ;done
2、apache编译
- # tar xvf httpd-2.2.9.tar.gz
- # cd httpd-2.2.9
- # ./configure ——prefix=/usr/local/apache2 ——enable-so
- # make
- # make install
三、tomcat安装
- # tar xvf apache-tomcat-6.0.32.tar.gz
- # cp -ar apache-tomcat-6.0.32 /usr/local
- # ln -s apache-tomcat-6.0.32 tomcat
四、java环境配置
- # mkdir /usr/java
- # cp jdk-1_5_0_06-linux-i586.bin /usr/java
- # cd /usr/java
- # bash jdk-1_5_0_06-linux-i586.bin
这样java jdk将安装到系统/usr/java/jdk1.5.0_06中
五、编译生成mod_jk<用于连接apache与tomcat的桥梁>
- # tar xvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
- # cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/
- # ./configure --with-apxs2=/usr/local/apache2/bin/apxs
- # make
- # cd ../build/jk2/apache2/
- # /usr/local/apache2/bin/apxs -n jk2 -i mod_jk2.so
- # ll /usr/local/apache2/modules/
- total 788
- -rw-r--r-- 1 root root 8998 Jun 8 10:14 httpd.exp
- -rwxr-xr-x 1 root root 778870 Jun 8 10:21 mod_jk2.so
- # cd /usr/local/apache2/conf/
- # vi mod_jk2.conf
- 添加如下:
- # 指出mod_jk模块工作所需要的工作文件workers2.properties的位置
- JkWorkersFile /usr/local/apache2/conf/workers2.properties
- # Where to put jk logs
- JkLogFile /usr/local/apache2/logs/mod_jk.log
- # 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"
- # 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
- JkMount /servlet/* worker1
- JkMount /*.jsp worker1
- # vi workers2.properties
- 添加如下:
- # Define the communication channel
- [channel.socket:localhost:8009]
- info=Ajp13 forwarding over socket
- tomcatId=localhost:8009
-
- # Map the Tomcat examples webapp to the Web server uri space
- [uri:/*.jsp]
- info=Map the whole webapp
-
配置httpd.conf
在添加:
- LoadModule jk2_module modules/mod_jk2.so
六、配置tomcat启动脚本
- # cp /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
- # vi /etc/init.d/tomcat
- 在第二行加入如下内容:
- # chkconfig: 345 88 14
- # description: Tomcat Daemon
- # processname: tomcat
- JAVA_HOME=/usr/java/jdk1.5.0_06
- CATALINA_HOME=/usr/local/tomcat
- # chmod 755 /etc/init.d/tomcat
- # chkconfig --add tomcat
- # chkconfig tomcat on
|