参考网址:
http://www.linuxquestions.org/questions/showthread.php?t=429037
http://www.howtoforge.com/apache2_tomcat5_mod_jk_p1
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] Error 1
修改Makefile 和common/Makefile两个文件
找到
LIBTOOL = /usr/share/apr-1.0/build/libtool --silent
改为
LIBTOOL = /usr/share/apr-1.0/build/libtool --silent --tag CC
(8) make install 执行后应该在/usr/local/apache2/modules/可以看到mod_jk.so
5 Configuring Tomcat and Apache
Create the workers.properties file
Important note: Be sure to make a backup copy of your config files before modifying.
The workers.properties file contains the details about how each process is linked to Tomcat by defining workers that communicate through the ajpv13 protocol. Refer to the Workers HowTo for more detail.
1.First create the workers.properties file in your Apache2 root directory.
touch /usr/local/apache2/conf/workers.properties
2.Next, open the workers.properties file and add the following.
You can find many other examples of the workers.properties file on the internet,
but this is the one that I created and it seems to work fine with the other portions
that have already been configured in this tutorial.
在workers.properties加入以下内容:
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/jre1.6.0_01
ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
3 保存并关闭文件
4. Now we need to open the /usr/local/apache2/conf/httpd.conf file and add the following lines at the bottom.
(httpd.conf is just for backward compatibility)
在最后加入 以下内容
LoadModule jk_module /usr/local/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/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 /*.jsp worker1
JkMount /*.do worker1
保存修改
(5) 修改
/usr/local/apache2/conf/extra/httpd-vhost.conf
修改,指定到应用程序中
DocumentRoot /var/www/test/
<Directory /var/www/test/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
并把 Options Indexes FollowSymLinks MultiViews
改成 Options FollowSymLinks MultiViews
保存修改
(6) 重启 tomcat
然后 /usr/local/apache2/bin/apachectl restart
这样apache就会把jsp请求交给tomcat来处理了
http://www.linuxquestions.org/questions/showthread.php?t=429037
http://www.howtoforge.com/apache2_tomcat5_mod_jk_p1
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] Error 1
修改Makefile 和common/Makefile两个文件
找到
LIBTOOL = /usr/share/apr-1.0/build/libtool --silent
改为
LIBTOOL = /usr/share/apr-1.0/build/libtool --silent --tag CC
(8) make install 执行后应该在/usr/local/apache2/modules/可以看到mod_jk.so
5 Configuring Tomcat and Apache
Create the workers.properties file
Important note: Be sure to make a backup copy of your config files before modifying.
The workers.properties file contains the details about how each process is linked to Tomcat by defining workers that communicate through the ajpv13 protocol. Refer to the Workers HowTo for more detail.
1.First create the workers.properties file in your Apache2 root directory.
touch /usr/local/apache2/conf/workers.properties
2.Next, open the workers.properties file and add the following.
You can find many other examples of the workers.properties file on the internet,
but this is the one that I created and it seems to work fine with the other portions
that have already been configured in this tutorial.
在workers.properties加入以下内容:
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/jre1.6.0_01
ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
3 保存并关闭文件
4. Now we need to open the /usr/local/apache2/conf/httpd.conf file and add the following lines at the bottom.
(httpd.conf is just for backward compatibility)
在最后加入 以下内容
LoadModule jk_module /usr/local/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/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 /*.jsp worker1
JkMount /*.do worker1
保存修改
(5) 修改
/usr/local/apache2/conf/extra/httpd-vhost.conf
修改,指定到应用程序中
DocumentRoot /var/www/test/
<Directory /var/www/test/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
并把 Options Indexes FollowSymLinks MultiViews
改成 Options FollowSymLinks MultiViews
保存修改
(6) 重启 tomcat
然后 /usr/local/apache2/bin/apachectl restart
这样apache就会把jsp请求交给tomcat来处理了