apache和tomcat动静分离

1、需要的软件

Httpd-2.2.17.tar.gz

Apache-tomcat-6.tar.gz

tomcat-connectors-1.2.31-src.tar.gz

JDK-6u25-dlj-linux-i586.bin

2、java的安装

3、apache的安装

3.1tar-zxvfhttpd-2.2.17.tar.gz

3.2cdhttpd-2.2.17

3.3./configure--prefix=/usr/local/apache--enable-modules=most--enable-mods-shared=all--enable-so

enable-so是必须要有的,是一个加载模块的开关

3.4make

3.5makeinstall

4、tomcat的安装

5、jakarta-tomcat-connectors安装

5.1tarxzvfjakarta-tomcat-connectors-1.2.31-src.tar.gz

5.2cdjakarta-tomcat-connectors-1.2.31-src/native

5.3./buildconf.sh

5.4./configure--with-apxs=/usr/local/apache/bin/apxs--with-java-home=/usr/local/jdk1.6.0_33/

5.5make

5.6makeinstall

5.7ll./apache-2.0/mod_jk.so/usr/local/apache/modules/mod_jk.so

结果会看到两个文件

6、想apache添加两个配置文件

6.1、cd/usr/local/apache2/conf

#vimmod_jk.conf

添加如下内容:

######指出mod_jk模块工作所需要的工作文件workers.properties的位置

JkWorkersFile/usr/local/apache2/conf/workers.properties

######Wheretoputjklogs

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

######Setthejkloglevel[debug/error/info]

JkLogLevelinfo

######Selectthelogformat

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

######JkOptionsindicatetosendSSLKEYSIZE,

JkOptions+ForwardKeySize+ForwardURICompat-ForwardDirectories

######JkRequestLogFormatsettherequestformat

JkRequestLogFormat"%w%V%T"

######将所有servlet和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理

JkMount/servlet/*worker1

JkMount/*.jspworker1

JkMount/*.doworker1

######也可以JkMount/应用名称/*worker2

6.2、cd/usr/local/apache2/conf

Vimworkers.properties

#######Definingaworkernamedworker1andoftypeajp13

worker.list=worker1

#######Setpropertiesforworker1

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

7、最后配置apache服务器配置文件,让apache加载mod_jk.so模块和读取mod_jk.conf文件

#vimhttpd.conf

在相应的位置添加上LoadModule的最后一个行。和<IfModule>前面

LoadModulejk_modulemodules/mod_jk.so

Include/usr/local/apache2/conf/mod_jk.conf

8、其他配置

ServerNameip:80

ListenIP:80

9、最后重启apache和tomcat即可完成

Apache的启动:

#/usr/local/apache/bin/apachectlstart

Tomcat的启动:

#/usr/local/tomcat/bin/startup.shstart

相关推荐