首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

apache mod_jk编译装配

2012-10-28 
apache mod_jk编译安装http://hi.baidu.com/chxl1209/blog/item/5524be351c45a3b25edf0e21.html操作系统:C

apache mod_jk编译安装
http://hi.baidu.com/chxl1209/blog/item/5524be351c45a3b25edf0e21.html

操作系统:CentOS release 5.5 (Final)

jdk:jdk-6u26-linux-i586-rpm.bin

apache:httpd-2.2.19.tar.gz

tomcat:apache-tomcat-7.0.14.tar.gz

另外:tomcat-connectors-1.2.32-src.tar.gz



1、安装jdk

[root@localhost ~]# chmod a+x jdk-6u26-linux-i586-rpm.bin

[root@localhost ~]# ./jdk-6u26-linux-i586-rpm.bin

#vi /etc/profile

在最后面加入

#set java environment

JAVA_HOME=/usr/java/jdk1.6.0_26

CLASSPATH=.:$JAVA_HOME/lib.tools.jar

PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME CLASSPATH PATH

保存退出。

要使JDK在所有的用户中使用,可以这样:

vi /etc/profile.d/java.sh

在新的java.sh中输入以下内容:

#set java environment

JAVA_HOME=/usr/java/jdk1.6.0_26

CLASSPATH=.:$JAVA_HOME/lib/tools.jar

PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME CLASSPATH PATH

保存退出,然后给java.sh分配权限:chmod 755 /etc/profile.d/java.sh

在终端使用echo命令检查环境变量设置情况。

#echo $JAVA_HOME

#echo $CLASSPATH

#echo $PATH

检查JDK是否安装成功。

#java -version

如果看到JVM版本及相关信息,即安装成功!



2、安装apache

[root@localhost ~]# tar -zxvf httpd-2.2.19.tar.gz

[root@localhost ~]# cd httpd-2.2.19

[root@localhost httpd-2.2.19]#  ./configure --prefix=/usr/local/apache --enable-module=so --enable-rewrite

[root@localhost httpd-2.2.19]# make ; make install



3、安装tomcat

[root@localhost ~]# tar -zxvf apache-tomcat-7.0.14.tar.gz  -C /usr/local/

[root@localhost local]# mv /usr/local/apache-tomcat-7.0.14 /usr/local/tomcat



4、安装mod_jk

[root@localhost ~]# tar -zxvf tomcat-connectors-1.2.32-src.tar.gz

[root@localhost ~]# cd tomcat-connectors-1.2.32-src/native/

[root@localhost native]# ./configure --with-apxs=/usr/local/apache/bin/apxs

[root@localhost native]# make ;make install



5、配置

在/usr/local/apache/conf/下面建立两个配置文件mod_jk.conf和workers.properties

[root@localhost conf]# vi mod_jk.conf

JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/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"
JkMount /servlet/* worker1
JkMount /*.jsp worker1



[root@localhost conf]# vi workers.properties

# Defining a worker named worker1 and of type ajp13

worker.list=worker1
# Set properties for worker1

worker.worker1.type=ajp13

worker.worker1.host=localhost

worker.worker1.port=8009

worker.worker1.lbfactor=50

worker.worker1.cachesize=10

worker.worker1.cache_timeout=600

worker.worker1.socket_keepalive=1

worker.worker1.socket_timeout=300



[root@localhost conf]# vi httpd.conf

在DirectoryIndex中添加 index.jsp

在最后添加:

LoadModule jk_module modules/mod_jk.so

Include /usr/local/apache/conf/mod_jk.conf



在/usr/local/tomcat/conf/ 下

[root@localhost conf]# vi server.xml

在HOST段中加入:
<Context path="" docBase="/usr/local/apache/htdocs" debug="0" reloadable="true" crossContext="true"/>



在/usr/local/apache/htdocs下建立一个index.jsp,启动Apache和Tomcat,就可以正常访问了。

热点排行