歡迎您光臨本站 註冊首頁

又是apache和tomcat的JK整合,折磨死我了,

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

又是apache和tomcat的JK整合,折磨死我了,

我模仿http://blog.ossxp.com/2010/01/296/,重新安裝了我的apache和tomcat,
現在他們的版本分別為
apache 2.2.17
tomcat 7.0.12
JK 1.2-30

按照這個博文整合前,apache(IP)和tomcat(IP:8080)分別好用。
整合后,沒有錯誤提示,但是,我訪問IP時,apache主頁沒有問題,訪問IP/tomcheck.jsp,是顯示源代碼。訪問IP:8080時,沒有錯誤信息,頁面為空白。在tomcat下部署的服務,正常我訪問IP:8080/geoserver,(正常能出現Geoserver的主界面才對)。也一樣沒有錯誤提示,只出現一個空白頁。

大俠們,幫我看看該怎麼配置吧,我真的是一頭霧水

apache的httpd.conf文件如下:
ServerRoot "/usr/local/apache2"


#Listen 12.34.56.78:80
Listen myIP:80


#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User yrf
Group yrf

</IfModule>
</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#


ServerAdmin you@example.com


ServerName myIP:80


DocumentRoot "/usr/local/apache2/htdocs"


<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>


<Directory "/usr/local/apache2/htdocs">
   
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.jsp
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>


ErrorLog "logs/error_log"


LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

   
    #
    CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock logs/cgisock
</IfModule>


<Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>


DefaultType text/plain

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
然後我在tomcat的context.xml下添加了context
<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>
<Context path="" docBase="/usr/local/apache2/htdocs" debug="0" reloadable="true" crossContext="true"/>其實就是添加了最後一行

同樣的,在server.xml里也添加了這行,
<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
   
   
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->        

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

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

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>
<Context path="" docBase="/usr/local/apache2/htdocs" debug="0" reloadable="true" crossContext="true"/>

      </Host>
    </Engine>
  </Service>
</Server>
添加了最後一行,其他沒變

能不能幫我看下,是不是哪裡設置不對了~~~{:3_201:}
《解決方案》

訪問IP:8080時,沒有錯誤信息,頁面為空白。

>>>>>>>>>>>>>>>正常的話會顯示那隻貓的頁面的,估計這裡就錯了。看看jdk的配置正確嗎。
《解決方案》

回復 2# linkiang


    不是的,沒有配置JK選項的話,單獨啟動tomcat是可以看到那個貓的頁面的,設置了連接后,就不行了
《解決方案》

tomcat 7.0.12已經不需要jk了,和apache整合以後反而降低性能.
單獨用就可以了
《解決方案》

回復 4# realmon


    哦,是嗎,這樣倒是方便了,有文獻支持嗎,給我發個鏈接看下唄。呵呵。
《解決方案》

現在tomcat獨自跑,php用nginx.......
《解決方案》

回復 6# c2shield


    單獨使用是可以,可是現在我很想跑通兩者的整合問題,為什麼就是不成功呢,汗
《解決方案》

本帖最後由 realmon 於 2011-04-26 09:17 編輯

參考
http://tomcat.apache.org/tomcat-7.0-doc/connectors.html
AJP下那一段話,大概意思是沒有特殊需要就不需要用jk了
我原來的apache+tomcat已經改為用LVS+jk了

至於jk的問題,你把log發出來看看 /etc/httpd/logs/mok_jk.log
《解決方案》

回復 8# realmon
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
worker1 202.199.230.171 0.035937
worker1 202.199.230.171 0.002314
worker1 202.199.230.171 0.000372
worker1 202.199.230.171 0.000346
worker1 202.199.230.171 0.000361
worker1 202.199.230.171 0.000346
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
worker1 202.199.230.171 0.008260
worker1 202.199.230.171 0.002223
worker1 202.199.230.171 0.002185
"mod_jk.log" 20L, 1711C                                       1,1           Top
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
worker1 202.199.230.171 0.035937
worker1 202.199.230.171 0.002314
worker1 202.199.230.171 0.000372
worker1 202.199.230.171 0.000346
worker1 202.199.230.171 0.000361
worker1 202.199.230.171 0.000346
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
worker1 202.199.230.171 0.008260
worker1 202.199.230.171 0.002223
worker1 202.199.230.171 0.002185
worker1 202.199.230.171 0.000375
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized
worker1 202.199.230.171 0.063182
這是我所有的jklog,最近因為著急要做後面的實驗,所以把jk整合的部分都註釋掉了,可還是很想能把這部分整合上
《解決方案》

我的配置文件供你參考
/etc/httpd/conf.d/jk.confLoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.x.so

<ifmodule mod_jk.c>
JkWorkersFile /etc/httpd/conf/workers.properties
JkLogFile /etc/httpd/logs/mod_jk.log
JkShmFile logs/mod_jk.shm
JkLogLevel warn
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkMount /*.do hhlb
JkMount /*.jsp hhlb
JkMount /manager/* hhlb
</ifmodule>

# vim:ft=apache:/etc/httpd/conf/workers.properties#====== list all app servers here ======
worker.list=hhlb,tomcat001,tomcat002
#recovery_options=3 # do not recovery
#====== balancer ======
worker.hhlb.type=lb
worker.hhlb.balance_workers=tomcat001,tomcat002  # replaces old balanced_workers directive for mod_jk 1.2.7 +.
worker.hhlb.sticky_session=1
#====== tomcat001 ======
worker.tomcat001.port=8009
worker.tomcat001.host=192.168.1.200
worker.tomcat001.type=ajp13
worker.tomcat001.lbfactor=1
#====== tomcat002 ======
worker.tomcat002.port=8009
worker.tomcat002.host=192.168.1.201
worker.tomcat002.type=ajp13
worker.tomcat002.lbfactor=1

[火星人 ] 又是apache和tomcat的JK整合,折磨死我了,已經有853次圍觀

http://coctec.com/docs/service/show-post-14605.html