apache tomcat 整合

10 07月
作者:PK|分类:工作

apache:Apache/2.4.4

tomcat:Apache Tomcat/6.0.37

jdk:1.7.0_25

先装jdk

tar zxvf jdk-7u25-linux-i586.tar.gz
mv jdk1.7.0_25/ /usr/local/jdk
vi + /etc/profile
#文件最后加入
JAVA_HOME=/usr/local/jdk
JRE_HOME=/usr/local/jdk/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
source /etc/profile #变量立即生效




再装apache

tar zxvf httpd-2.4.4.tar.gz
cd httpd-2.4.4
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make && make install

接着装tomcat

tar zxvf apache-tomcat-6.0.37.tar.gz
mv apache-tomcat-6.0.37 /usr/local/tomcat

安装jk_mod模块

tar zxvf tomcat-connectors-1.2.31-src.tar.gz
cd tomcat-connectors-1.2.31/native
./configure --with-apxs=/usr/local/apache/bin/apxs
make && make install
# jk conn_rec' has no member named 'remote_ip的解决方法
#mod_wsgi.c文件(在native/apapche-2.0下)改一下,把remote_ip和remote_addr分别替换成client_ip和client_addr,

整合apache和tomcat

在/etc/httpd/extra/下面 新建mod_jk.conf 内容如下

JkWorkersFile        conf/extra/workers.properties
JkLogFile        logs/mod_jk.log
JkShmFile        logs/jk-runtime-status
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
                        
#Sample JkMounts.   Replace these with the paths you would
#like to mount from your JSP server.
#syntax: JkMount ${URL_DIR}/*.jsp worker_name
                        
JkMount                /images/avatar/*        worker1
JkMount                /*.jsp                        worker1
JkMount                /*.page                     worker1
JkMount                /*.cic                        worker1
JkMount                /*.do                         worker1
JkMount                /*.action                    worker1
JkMount                /*                              worker1 #这个这样写可以处理那种不带后缀名的请求.
JKUnmount           /*.php                        worker1   # php请求不交给tomcat处理。可以使php和jsp共存.

再建一个workers.properties文件,内容如下


worker.list=worker1     
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.woker1.lbfactor=1

打开tomcat安装目录下面conf目录下的server.xml文件,找到


<Host name="localhost"  appBase="webapps"
                        unpackWARs="true" autoDeploy="true"
                        xmlValidation="false" xmlNamespaceAware="false">

在上面的文字后面加入

<Context path="" docBase="/usr/local/apache/htdocs" debug="0" reloadable="true" />

和apache的根目录地址一致.

重启apache,tomcat 测试



遇到一个问题,https://www.laomm.com/pm  pm下面是默认首页是index.php,结果是由tomcat处理.直接显示源代码.如果手动输入https://www.laomm.com/pm/index.php 就可以正常显示

搜了好久都不知道 暂时用跳转解决,新建一个index.html里面写上

<script>window.location = "index.php";</script>





浏览1036 评论0
返回
目录
返回
首页
Linux自己用的 rar.exe命令

发表评论