Apache 找不到名为';ajp13#U工人';

Apache 找不到名为';ajp13#U工人';,apache,tomcat9,Apache,Tomcat9,我有一个带有Apache2+Tomcat9的新Debian10服务器。由于内部服务器错误,我无法运行JSF页面。我认为错误在ApacheTomcat连接器(libapache2 mod jk)中 我使用openjdkv。11,我还使用ApacheTomcat本机库[1.2.23],使用APR版本[1.7.0]。 Tomcat定期运行,Apache也是如此 这是我的workers.properties文件: # workers.properties - # # Th

我有一个带有Apache2+Tomcat9的新Debian10服务器。由于内部服务器错误,我无法运行JSF页面。我认为错误在ApacheTomcat连接器(libapache2 mod jk)中

我使用openjdkv。11,我还使用ApacheTomcat本机库[1.2.23],使用APR版本[1.7.0]。 Tomcat定期运行,Apache也是如此

这是我的workers.properties文件:

        # workers.properties -
    #
    # This file is a simplified version of the workers.properties supplied
    # with the upstream sources. The jni inprocess worker (not build in the
    # debian package) section and the ajp12 (deprecated) section are removed.
    #
    # As a general note, the characters $( and ) are used internally to define
    # macros. Do not use them in your own configuration!!!
    #
    # Whenever you see a set of lines such as:
    # x=value
    # y=$(x)\something
    #
    # the final value for y will be value\something
    #
    # Normaly all you will need to do is un-comment and modify the first three
    # properties, i.e. workers.tomcat_home, workers.java_home and ps.
    # Most of the configuration is derived from these.
    #
    # When you are done updating workers.tomcat_home, workers.java_home and ps
    # you should have 3 workers configured:
    #
    # - An ajp13 worker that connects to localhost:8009
    # - A load balancer worker
    #
    #

    # OPTIONS ( very important for jni mode )

    #
    # workers.tomcat_home should point to the location where you
    # installed tomcat. This is where you have your conf, webapps and lib
    # directories.
    #
    workers.tomcat_home=/usr/share/tomcat9

    #
    # workers.java_home should point to your Java installation. Normally
    # you should have a bin and lib directories beneath it.
    #

    workers.java_home=/usr/lib/jvm/java-11-openjdk-amd64

    #
    # You should configure your environment slash... ps=\ on NT and / on UNIX
    # and maybe something different elsewhere.
    #
    ps=/

    #
    #------ ADVANCED MODE ------------------------------------------------
    #---------------------------------------------------------------------
    #

    #
    #------ worker list ------------------------------------------
    #---------------------------------------------------------------------
    #
    #
    # The workers that your plugins should create and work with
    #
    worker.list=ajp13_worker

    #
    #------ ajp13_worker WORKER DEFINITION ------------------------------
    #---------------------------------------------------------------------
    #

    #
    # Defining a worker named ajp13_worker and of type ajp13
    # Note that the name and the type do not have to match.
    #
    worker.ajp13_worker.port=8009
    worker.ajp13_worker.host=localhost
    worker.ajp13_worker.type=ajp13
    #
    # 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.ajp13_worker.lbfactor=1

    #
    # Specify the size of the open connection cache.
    #worker.ajp13_worker.cachesize

    #
    #------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
    #---------------------------------------------------------------------
    #

    #
    # The loadbalancer (type lb) workers perform wighted 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
    #        workers.
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=ajp13_worker
这是我的httpd-jk.conf文件:

        # 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.

    # Configuration Example for mod_jk
    # used in combination with Apache 2.2.x

    <IfModule jk_module>

        # We need a workers file exactly once
        # and in the global server
        JkWorkersFile /etc/libapache2-mod-jk/workers.properties

        # Our JK error log
        # You can (and should) use rotatelogs here
        JkLogFile /var/log/apache2/mod_jk.log

        # Our JK log level (trace,debug,info,warn,error)
        JkLogLevel debug

        # Our JK shared memory file
        JkShmFile /var/log/apache2/jk-runtime-status

        # Define a new log format you can use in any CustomLog in order
        # to add mod_jk specific information to your access log.
        # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\" \"%{Set-Cookie}o\" %{pid}P %{tid}P %{JK_LB_FIRST_NAME}n %{JK_LB_LAST_NAME}n ACC %{JK_LB_LAST_ACCESSED}n ERR %{JK_LB_LAST_ERRORS}n BSY %{JK_LB_LAST_BUSY}n %{JK_LB_LAST_STATE}n %D" extended_jk

        # This option will reject all requests, which contain an
        # encoded percent sign (%25) or backslash (%5C) in the URL
        # If you are sure, that your webapp doesn't use such
        # URLs, enable the option to prevent double encoding attacks.
        # Since: 1.2.24
        # JkOptions +RejectUnsafeURI

        # After setting JkStripSession to "On", mod_jk will
        # strip all ";jsessionid=..." from request URLs it
        # does *not* forward to a backend.
        # This is useful, if all links in a webapp use
        # URLencoded session IDs and parts of the static
        # content should be delivered directly by Apache.
        # Of course you can also do it with mod_rewrite.
        # Since: 1.2.21
        # JkStripSession On

        # Start a separate thread for internal tasks like
        # idle connection probing, connection pool resizing
        # and load value decay.
        # Run these tasks every JkWatchdogInterval seconds.
        # Since: 1.2.27
        JkWatchdogInterval 60

        # Configure access to jk-status and jk-manager
        # If you want to make this available in a virtual host,
        # either move this block into the virtual host
        # or copy it logically there by including "JkMountCopy On"
        # in the virtual host.
        # Add an appropriate authentication method here!
        <Location /jk-status>
            # Inside Location we can omit the URL in JkMount
            JkMount jk-status
            Require ip 127.0.0.1
        </Location>
        <Location /jk-manager>
            # Inside Location we can omit the URL in JkMount
            JkMount jk-manager
            Require ip 127.0.0.1
        </Location>

        # If you want to put all mounts into an external file
        # that gets reloaded automatically after changes
        # (with a default latency of 1 minute),
        # you can define the name of the file here.
        # JkMountFile conf/extra/uriworkermap.properties

        # Example for Mounting a context to the worker "balancer"
        # The URL syntax "a|b" instantiates two mounts at once,
        # the first one is "a", the second one is "ab".
        # JkMount /myapp|/* balancer

        # Example for UnMounting requests for all workers
        # using a simple URL pattern
        # Since: 1.2.26
        # JkUnMount /myapp/static/* *

        # Example for UnMounting requests for a named worker
        # JkUnMount /myapp/images/* balancer

        # Example for UnMounting requests using regexps
        # SetEnvIf REQUEST_URI "\.(htm|html|css|gif|jpg|js)$" no-jk

        # Example for setting a reply timeout depending on the request URL
        # Since: 1.2.27
        # SetEnvIf Request_URI "/transactions/" JK_REPLY_TIMEOUT=600000

        # Example for disabling reply timeouts for certain request URLs
        # Since: 1.2.27
        # SetEnvIf Request_URI "/reports/" JK_REPLY_TIMEOUT=0

        # IMPORTANT: Mounts and virtual hosts
        # If you are using VirtualHost elements, you
        # - can put mounts only used in some virtual host into its VirtualHost element 
        # - can copy all global mounts to it using "JkMountCopy On" inside the VirtualHost
        # - can copy all global mounts to all virtual hosts by putting
        #   "JkMountCopy All" into the global server
        # Since: 1.2.26

    </IfModule>
我的Apache是:

        <VirtualHost *:80>
    DocumentRoot "/var/www/vhosts/www.mydomain.com/ROOT"
    ServerName www.mydomain.com
    ServerAdmin info@mydomain.com

    JkMount /* ajp13_worker
    JkLogLevel debug


    <Directory "/var/www/vhosts/www.mydomain.com/ROOT">
    allow from all
    Options None
    Require all granted
    </Directory>
    </VirtualHost>

DocumentRoot“/var/www/vhosts/www.mydomain.com/ROOT”
服务器名www.mydomain.com
服务器管理员info@mydomain.com
JkMount/*ajp13_工人
日志级调试
通融
选项无
要求所有授权
Apache似乎找不到“ajp13_worker”worker

为什么?


谢谢。

您必须在apache文件中定义JK选项,在virtualhost之前,而不是在中。例如:

JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkLogFile ${APACHE_LOG_DIR}/mod_jk.log
JkLogLevel info                
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

jkworkers文件是必需的,其他文件是可选的。

您必须将JK配置文件从
httpd JK.conf
重命名为
JK.conf
。 这对我很有用:

$ sudo a2dismod jk
$ sudo mv /etc/apache2/mods-available/httpd-jk.conf /etc/apache2/mods-available/jk.conf
$ cd /etc/libapache2-mod-jk/
$ sudo ln -f -s ../apache2/mods-available/jk.conf httpd-jk.conf
$ sudo a2enmod jk
$ sudo apache2ctl configtest
$ sudo systemctl restart apache2

我遇到了这个问题。通过分析Apache日志(error.log),我注意到没有加载文件/etc/apache2/mods available/httpd-jk.conf(来自/etc/libapache2 mod jk/httpd jk.conf的符号链接),因为Apache修复了日志文件的默认名称(JkLogFile指令)。
然后只需将httpd-jk.conf文件复制到/etc/apache2/conf下即可,然后将此副本的符号链接设置为目标/etc/apache2/conf启用,一切正常。

sudo apache2ctl configtest AH00526:etc/apache2/sites enabled/example.com-le-ssl.conf的第1行出现语法错误:JkWorkersFile仅允许一次操作'configtest'失败。Apache错误日志可能包含更多信息。很抱歉,上面的评论是@Bernat针对下面的解决方案提出的,但您的解决方案没有解决问题,仍在获取无法找到工作程序名称UDO apache2ctl configtest AH00526:/etc/apache2/sites enabled/example.com-le-ssl.conf的第1行上的语法错误:只有在操作“configtest”失败时才允许jkWorkers文件。Apache错误日志可能包含更多信息。您能否分步解决此问题?
$ sudo a2dismod jk
$ sudo mv /etc/apache2/mods-available/httpd-jk.conf /etc/apache2/mods-available/jk.conf
$ cd /etc/libapache2-mod-jk/
$ sudo ln -f -s ../apache2/mods-available/jk.conf httpd-jk.conf
$ sudo a2enmod jk
$ sudo apache2ctl configtest
$ sudo systemctl restart apache2