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"/>
操作系统: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,就可以正常访问了。
- 下载httpd-2.2.15.tar.gz,使用tar zxvf httpd-2.2.15.tar.gz解压。如解压后的路径为:/software/httpd-2.2.15。
- 首先安装apr apr-util (不推荐)
- # cd /software/httpd-2.2.15/srclib/apr
- # ./configure --prefix=/usr/local/apr
- # make
- # make install
- #cd /software/httpd-2.2.15/srclib/apr-util
- #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- #make
- #make install
-
- 到官网http://apr.apache.org/
- 下载apr-1.4.2.tar.gz 和 apr-util-1.3.9.tar.gz
- tar zxvf apr-1.4.2.tar.gz
- cd apr-1.4.2
- ./configure --prefix=/usr/local/apr
- make
- make install
- tar zxvf apr-util-1.3.9.tar.gz
- cd apr-util-1.3.9
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- make
- make install
- 安装apache
- #cd /software/httpd-2.2.15
- #./configure --prefix=/usr/local/apache --enable-module=so --enable-mods-shared=all --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --with-mpm=worker --enable-ssl --enable-deflate --with-included-apr --enable-so --enable-rewrite=share --enable-proxy=share --enable-proxy-ajp=share --enable-dav=share --enable-dav-fs --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util
- #make
- #make install
- 如果出现以下错误,请检查系统中是否已经安装zlib
- checking for zlib location... not found
- checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
安装zlib如下:
- #tar -xvzf zlib-1.2.3.tar.gz
- #cd zlib-1.2.3
- #./configure
- #make
- # make install
如果出现以下错误,请检查是否已经安装OpenSSL
- checking for openssl/ssl.h... no
- no OpenSSL headers found
- checking for SSL-C version... checking sslc.h usability... no
- checking sslc.h presence... no
- checking for sslc.h... no
- no SSL-C headers found
- configure: error: ...No recognized SSL/TLS toolkit detected
请到http://www.openssl.org/source/下载最新版本。
安装openssl如下:
- 1、解压软件:
- # tar xvfz openssl-0.9.6b.tar.gz
- 2、安装
- # cd openssl-0.9.6b
- # ./config
- # make
- # make test
- # make install
如果问题还是无法解决,请输入以下命令去完成:
- apt-get install openssl libssl-dev
如果出现以下错误,请检查是否已经安装libtool
- libtool: install: error: cannot install `libaprutil-1.la' to a directory not ending in /usr/local/apr-util/lib
- make[2]: *** [install] 错误 1
- make[2]:正在离开目录 `/usr/java/httpd-2.2.15/srclib/apr-util'
- make[1]: *** [install-recursive] 错误 1
- make[1]:正在离开目录 `/usr/java/httpd-2.2.15/srclib'
- make: *** [install-recursive] 错误 1
在http://ftp.gnu.org/gnu/libtool/libtool-2.2.8.tar.gz下载。
安装libtool如下:
- tar zxvf libtool-2.2.8.tar.gz
- cd libtool-2.2.8
- ./configure
- make
- make install