1 安装 Apache
下载地址:http://httpd.apache.org/download.cgi
建议下载 2.2 最新稳定版
安装过程请参考:http://my.oschina.net/huangyong/blog/176924
假设安装目录为:/opt/apache
2 安装 Tomcat
下载地址:http://tomcat.apache.org/download-70.cgi
建议下载 7.0 最新稳定版
直接解压即可安装
假设安装目录为:/opt/tomcat
3 安装 Tomcat Connectors(mod_jk)
下载地址:http://tomcat.apache.org/download-connectors.cgi
建议下载 1.2 最新稳定版
安装过程如下:
1
2
3
4
5
6
|
tar
-zxf tomcat-connectors-1.2.37-src.
tar
.gz
cd
tomcat-connectors-1.2.37-src/
cd
native/
.
/configure
--with-apxs=
/opt/apache/bin/apxs
-q
make
-s
make
install
-s
|
在 configure 时,需指定 apxs 的路径
安装完毕后,将在 Apache 的 modules 目录下生成一份 mod_jk.so 文件
4 配置 Tomcat
修改 <TOMCAT>/conf/server.xml 文件
4.1 关闭 HTTP/1.1 协议
1
2
3
4
5
|
...
<!--<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />-->
...
|
4.2 开启 AJP/1.3 协议
1
2
3
|
...
<
Connector
port
=
"8009"
protocol
=
"AJP/1.3"
redirectPort
=
"8443"
/>
...
|
5 配置 Apache
修改 <APACHE>/conf/httpd.conf 文件
5.1 开启虚拟机配置
1
|
Include conf/extra/httpd-vhosts.conf
|
5.2 添加 JK 配置
1
|
Include conf/extra/httpd-jk.conf
|
5.3 配置 httpd-jk.conf 文件
1
2
3
4
5
6
|
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
|
5.4 配置 workers.properties 文件
1
2
3
4
5
|
worker.list=tomcat
worker.tomcat.
type
=ajp13
worker.tomcat.host=localhost
worker.tomcat.port=8009
|
5.5 配置 httpd-vhosts.conf 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
NameVirtualHost *:80
<
VirtualHost
*:80>
ServerName "www.xxx.com"
DocumentRoot "/opt/tomcat/webapps/ROOT/www"
ErrorLog "logs/www.xxx.com-error.log"
CustomLog "logs/www.xxx.com-access.log" common
<
Directory
"/opt/tomcat/webapps/ROOT/www">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</
Directory
>
JkMount /* tomcat
JkUnMount /css/* tomcat
JkUnMount /js/* tomcat
JkUnMount /lib/* tomcat
</
VirtualHost
>
|
6 启动 Apache 与 Tomcat
使用 www.xxx.com 访问应用