apache

操作系统: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 

#Wheretoputjklogs

JkLogFile/usr/local/apache/logs/mod_jk.log

#Setthejkloglevel[debug/error/info]

JkLogLevelinfo

#Selectthelogformat

JkLogStampFormat"[%a%b%d%H:%M:%S%Y]"

#JkOptionsindicatetosendSSLKEYSIZE,

JkOptionsForwardKeySizeForwardURICompat-ForwardDirectories

#JkRequestLogFormatsettherequestformat

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="/mid" docBase="/usr/local/apache/htdocs/mid" debug="0" reloadable="true" crossContext="true"/>

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

相关推荐