日期:2014-05-16  浏览次数:21025 次

使用jakarta-tomcat-connectors整合apache2和tomcat
1 Installing Apache2

下载apache
wget -c http://apache.mirror.phpchina.com/httpd/httpd-2.2.4.tar.bz2
解压缩后进入目录进行配置

./configure --enable-module=so --enable-module=usertrack --enable-modules=fastcgi --enable-info --enable-suexec --with-mpm=worker --enable-expires --enable-headers --enable-deflate --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache

make && make install

Edit /usr/local/apache2/conf/httpd.conf and change(修改apache2配置文件):

加入
DirectoryIndex index.htm index.html index.php index.xhtml index.shtml

/usr/local/apache2/bin/apachects start
启动apache2

2 Installing JDK (Java Development Kit) or JRE(Java Runtime Environment)

http://java.sun.com
下载 jdk 或 jre

chmod +x jre-6u4-linux-i586.bin
Now execute the file:
./jre-6u4-linux-i586.bin
mv jre1.6.0_04 /usr/local/

Now we need to set the JAVA_HOME environment variable. Add the following at the end of /etc/profile just after export PATH.

vi /root/.bashrc
加入
JAVA_HOME=/usr/local/jre1.6.0_04
PATH=$JAVA_HOME:$JAVA_HOME/bin:$PATH
#CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH

重新登陆系统后
echo $JAVA_HOME
就会打印JAVA_HOME

3 Installing Tomcat
http://tomcat.apache.org
下载tomcat

执行
tar xvzf apache-tomcat-6.0.14.tar.gz

进入
TOMCAT_HOME/bin/

执行./startup.sh

启动 进入 http://localhost:8080/ 就表示成功

4 Installing and configuring mod_jk
(1) cd /usr/src

(2) 首先下载(wget http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz)
http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz

(3) tar xvzf jakarta-tomcat-connectors-1.2.15-src.tar.gz

(4) cd jakarta-tomcat-connectors-1.2.15-src/jk/native

(5) Now you are ready to create the custom configure file for your system. Execute the following:

    ./buildconf.sh
 
    如果提示失败,最好下载
    autoconf,automake,libtool
   
 
    This will create a configure file in the
    /usr/src/jakarta-tomcat-connectors-1.2.15-src/jk/native directory.

(6) Execute the following command in order to configure mod_jk for your system.
    Important note: You will need to have apxs2 (APache eXtension tool) installed and configured with Apache.
    If you do not have it, as was my case, you can download and install the apache2-threaded-dev package
    (which replaced the former apache-dev package) from www.debian.org.
    At the time of this writing, the Debian package archive at www.debian.org was down and
    they referred me to their temporary site until they resolved their issues pdo.debian.net.
    I found the apache2-threaded-dev package and was able to install it successfully.
    Be sure to include the correct location apxs2 on your system in the path of the command.


    ./configure --with-apxs=/usr/local/apache2/bin/apxs

(7) 执行make
 
    在执行make 时可能会出现
 
    libtool: compile: unable to infer tagged configuration
    libtool: compile: specify a tag with `--tag'
    make[1]: *** [jk_ajp12_worker.lo] Error 1
    make[1]: Leaving directory `/usr/src/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'
    make: *** [all-recursive] Er