免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 7463 | 回复: 25
打印 上一主题 下一主题

apache+tomcat 配置JSP问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-15 23:57 |只看该作者 |倒序浏览
rhel5
apache已经配置好,访问http://rhel/无问题
tomcat已经配置好,访问http://rhel:8080/examples/无问题,自己写的jsp文件,通过http://rhel:8080/examples/servlets/helloworld.jsp访问已经没有问题
按照相关资料配置apache和tomcat的整合,可访问http://rhel/helloworld.jsp,老是报错:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.


--------------------------------------------------------------------------------

Apache/2.2.3 (Red Hat) Server at rhel Port 80

请问是什么问题。谢谢
附相关配置文件内容如下:



配置文件:
workers.properties:

#
# workers.properties
#
# In Unix, we use forward slashes:
ps=/
# list the workers by name
worker.list=tomcat1, tomcat2, loadbalancer
# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=8008
worker.tomcat1.host=127.0.0.1
worker.tomcat1.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat1.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=100
# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=8008
worker.tomcat2.host=172.24.58.121
worker.tomcat2.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat2.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat2.lbfactor=100
# ------------------------
# Load Balancer worker
# ------------------------
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2
#
# END workers.properties
#


httpd.conf:


......
LoadModule jk_module modules/mod_jk.so
# Configure mod_jk
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /*.jsp loadbalancer
JkMount /servlet/* loadbalancer
JkMount /application/* loadbalancer



server.xml:

<!-- 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">

  <!--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" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- 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" protocolHandlerclassName="org.apache.jk.server.JkCoyoteHandler"
               c
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
   
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               c
               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 8008 -->
    <Connector port="8008" 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="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
     
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

      <!--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"/>
      -->        

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- 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"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- 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 -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
    <!--
    <Engine name="DSO" defaultHost="172.24.58.121" jvmRoute="tomcat2"></Engine>
    -->
  </Service>
</Server>

[ 本帖最后由 kerberospeng 于 2007-6-17 01:34 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-06-16 00:42 |只看该作者
你是用jk_mod把,需要在http.conf里mount helloworld.jsp

论坛徽章:
0
3 [报告]
发表于 2007-06-16 01:15 |只看该作者
JkMount /*.jsp loadbalancer
这样不行吗?
难道 每个页面都需要mount?
谢谢

论坛徽章:
0
4 [报告]
发表于 2007-06-16 13:02 |只看该作者
我昨天晚上刚把apache 和tomcat 整合好
你把这句加到 host 段试试

  1.   <Context path="" docBase="/usr/local/apache2/htdocs" debug="0" reloadable="true" crossContext="true" />
复制代码

直接访问 localhost/hello.jsp  对应/usr/local/apache2/htdocs/hello.jsp

论坛徽章:
0
5 [报告]
发表于 2007-06-16 14:35 |只看该作者
还是不行,只是改变了文档起始位置。

论坛徽章:
0
6 [报告]
发表于 2007-06-17 01:20 |只看该作者
原来kerberospeng加我是这个原因,我帖一下我是如何整和的过程把:

6,安装mod_jk
# cd /usr/local/src
# tar zxvf tomcat-connectors-1.2.23-src.tar.gz
# cd tomcat-connectors-1.2.23-src/native/
# ./configure --with-apxs=/usr/local/apache2/bin/apxs
# make
# make install
# cd ../conf
# cp workers.properties.minimal /usr/local/apache2/conf/workers.properties
# cd /usr/local/apache2/conf/
# vi http.conf
加入:
LoadModule jk2_module modules/mod_jk2.so

在文件底部加入:
  JkWorkersFile /usr/local/apache2/conf/workers.properties
  JkLogFile "logs\mod_jk2.log"
  JkLogLevel info
  jkMount /*.jsp wlb
  jkMount /  wlb

论坛徽章:
0
7 [报告]
发表于 2007-06-17 01:25 |只看该作者
说一句话mod_jk2这个东西自己玩玩就行了,如果是商用的话还是免了

论坛徽章:
0
8 [报告]
发表于 2007-06-17 01:33 |只看该作者
我的步骤跟你相同,不过我编译得到的是mod_jk.so,但是但现在通过apache访问jsp就是不成功。我的配置文件如上。
请大虾帮我看看,问题在什么地方

另外,如果商用,该用什么?
谢谢!

[ 本帖最后由 kerberospeng 于 2007-6-17 01:36 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2007-06-17 01:35 |只看该作者
mod_jk.log:


[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  service::jk_lb_worker.c (1136): Forcing recovery once for 2 workers
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  jk_open_socket::jk_connect.c (451): connect to 127.0.0.1:8008 failed (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_connect_to_endpoint::jk_ajp_common.c (876): Failed opening socket to (127.0.0.1:800 (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_send_request::jk_ajp_common.c (1273): (tomcat1) error connecting to the backend server (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_service::jk_ajp_common.c (1941): (tomcat1) sending request to tomcat failed,  recoverable operation attempt=1
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  jk_open_socket::jk_connect.c (451): connect to 127.0.0.1:8008 failed (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_connect_to_endpoint::jk_ajp_common.c (876): Failed opening socket to (127.0.0.1:800 (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_send_request::jk_ajp_common.c (1273): (tomcat1) error connecting to the backend server (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_service::jk_ajp_common.c (1941): (tomcat1) sending request to tomcat failed,  recoverable operation attempt=2
[Sun Jun 17 00:20:39 2007] [4207:22752] [error] ajp_service::jk_ajp_common.c (1953): (tomcat1) Connecting to tomcat failed. Tomcat is probably not started or is listening on the wrong port
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  service::jk_lb_worker.c (109: service failed, worker tomcat1 is in error state
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  jk_open_socket::jk_connect.c (451): connect to 172.24.58.121:8008 failed (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_connect_to_endpoint::jk_ajp_common.c (876): Failed opening socket to (172.24.58.121:800 (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_send_request::jk_ajp_common.c (1273): (tomcat2) error connecting to the backend server (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_service::jk_ajp_common.c (1941): (tomcat2) sending request to tomcat failed,  recoverable operation attempt=1
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  jk_open_socket::jk_connect.c (451): connect to 172.24.58.121:8008 failed (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_connect_to_endpoint::jk_ajp_common.c (876): Failed opening socket to (172.24.58.121:800 (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_send_request::jk_ajp_common.c (1273): (tomcat2) error connecting to the backend server (errno=111)
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  ajp_service::jk_ajp_common.c (1941): (tomcat2) sending request to tomcat failed,  recoverable operation attempt=2
[Sun Jun 17 00:20:39 2007] [4207:22752] [error] ajp_service::jk_ajp_common.c (1953): (tomcat2) Connecting to tomcat failed. Tomcat is probably not started or is listening on the wrong port
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  service::jk_lb_worker.c (109: service failed, worker tomcat2 is in error state
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  service::jk_lb_worker.c (1160): All tomcat instances are busy or in error state
[Sun Jun 17 00:20:39 2007] [4207:22752] [info]  jk_handler::mod_jk.c (2254): Service error=0 for worker=loadbalancer

论坛徽章:
0
10 [报告]
发表于 2007-06-17 01:54 |只看该作者
原帖由 kerberospeng 于 2007-6-17 01:33 发表于 8楼  
我的步骤跟你相同,不过我编译得到的是mod_jk.so,但是但现在通过apache访问jsp就是不成功。我的配置文件如上。
请大虾帮我看看,问题在什么地方

另外,如果商用,该用什么?
谢谢!



商用的话一般都用weblogic,

我加你QQ没反应阿

linux这东西安装的时候我一般都是把所有的开发包全部装,其他的都不装
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP