centos apache 整合 php tomcat

服務器以前一直跑php 如今但願整合下tomcat ,讓服務器同時支持php 和java。php

先安裝好jdk 和tomcat。
java

yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
wget   http://apache.fayea.com/tomcat/tomcat-6/v6.0.45/bin/apache-tomcat-6.0.45.tar.gz
tar -zxvf apache-tomcat-6.0.45.tar.gz
mv apache-tomcat-6.0.45.tar.gz /usr/local/tomcat6web

/usr/local/tomcat6/bin/startup.sh
apache

而後瀏覽器:http://IP:8080/ 能夠看到主頁了。瀏覽器


apache 和 tomcat整合tomcat

  1. 安裝mod_jk.so
    服務器

    wget http://apache.fayea.com/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gzapp

        tar zxvf    tomcat-connectors-1.2.41-src.tar.gzsocket

        cd  /usr/local/tomcat-connectors-1.2.41-src/nativejsp

         ./configure --with-apxs=/usr/sbin/apxs

          make

          cp ./apache-2.0/mod_jk.so /etc/httpd/modules/

          

2. 配置apache2

在/etc/httpd/conf/下面創建兩個配置文件mod_jk.conf和workers.properties

# vi mod_jk.conf

添加如下內容:

# 指出mod_jk模塊工做所須要的工做文件workers.properties的位置
JkWorkersFile /etc/httpd/conf/workers.properties

# Where to put jk logs
JkLogFile/etc/httpd/logs/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"

# 將全部servlet 和jsp請求經過ajp13的協議送給Tomcat,讓Tomcat來處理
JkMount /servlet/*  worker1
JkMount /*.jsp worker1
 

# vi workers.properties
添加如下內容:

# Defining a worker named worker1 and of type ajp13
worker.list=worker1

# Set properties for worker1
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


配置httpd.conf,做如下修改:
在DirectoryIndex中添加 index.jsp
個人網頁放在/var/wwwroot下,因此要修改DocumentRoot

DocumentRoot "/var/wwwroot"
<Directory "/var/wwwroot">
    Options Includes FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
    XBitHack on
</Directory>
<Directory "/var/wwwroot/WEB-INF">     
    Order deny,allow
    Deny from all
</Directory>
 


增長關於加載mod_jk的語句:

LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
 



最後編輯Tomcat的配置文件server.xml,在HOST段中加入:

<Context path="" docBase="/var/wwwroot" debug="0" reloadable="true" crossContext="true"/>

















tomcat 需哦項目部署:vi /usr/local/tomcat6/conf/server.xml

<Host name="www.zikaos.net"  appBase="/var/www"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Alias>www.zikaos.net</Alias>
        <Context path="" docBase="tophr" debug="0" reloadable="true"/>
</Host> 


<Host name="www.gaoks.com"  appBase="/var/www"            unpackWARs="true" autoDeploy="true"            xmlValidation="false" xmlNamespaceAware="false">        <Alias>www.gaoks.com</Alias>        <Context path="" docBase="gaoks" debug="0" reloadable="true"/></Host>

相關文章
相關標籤/搜索