Configuring apache tomcat with mod_jk and ispconfig

Discussion in 'Installation/Configuration' started by showe1966, Sep 20, 2007.

  1. showe1966

    showe1966 Member

    Okay next question:-

    Can anyone point me to a guide on how to install tomcat and the mod-jk apache connector on Ubuntu 7.04 , including secure socket layer to encrypt web communcations ?

    I got part of the way though the guide on this website before i realized most of the work in the first 3 pages of the guide can be done using:-

    apt-get install libapache2-mod-jk

    However, I am not sure how to move on from that point as it is not clear to me how ispconfig interacts with the standard apache2 settings and configuration files.

    Can anyone point me in the right direction ?

    Thanks a lot
  2. torusturtle

    torusturtle ISPConfig Developer ISPConfig Developer

  3. showe1966

    showe1966 Member

    not working for me

    That howto is not working for me.
    1. Building from source does not work, so I just used the "apt-get libapache2-mod-jk " method.

    2. I tried following all the steps of this tutorial, but when I re-start tomcat after modifying the and server.xml files, tomcat crashed as follows.
    My questions would be:-
    1. Can anyone point me to a document that explains how to write the server.xml file ?
    2. Is there any way to cut all the c**p out of the server.xml file so it is easier to read ?

    Sep 20, 2007 7:46:37 PM org.apache.catalina.startup.Catalina load
    WARNING: Catalina.start using conf/server.xml:
    java.lang.ClassNotFoundException: org.apache.catalina.storeconfig.StoreConfigLifecycleListener
    at org.apache.tomcat.util.digester.Digester.createSAXException(
    at org.apache.tomcat.util.digester.Digester.createSAXException(
    at org.apache.tomcat.util.digester.Digester.startElement(
    at org.apache.tomcat.util.digester.Digester.parse(
    at org.apache.catalina.startup.Catalina.load(
    at org.apache.catalina.startup.Catalina.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.apache.catalina.startup.Bootstrap.start(
    at org.apache.catalina.startup.Bootstrap.main(
    Sep 20, 2007 7:46:37 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 0 ms
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.apache.catalina.startup.Bootstrap.start(
    at org.apache.catalina.startup.Bootstrap.main(
    Caused by: java.lang.NullPointerException
    at org.apache.catalina.startup.Catalina.await(
    at org.apache.catalina.startup.Catalina.start(
    ... 6 more
  4. showe1966

    showe1966 Member

    everything working now

    My software bod got everything working for me, so I am a little hazy on the details, however he had mod_jk working on a non-virtual server previously and he tells me that all you have to do to getting working under ispconfig and virtual hosts is paste the code you had in your original httpd.conf file into the following file:-

    I think there may be more to it that that, but that is what he tells me....
  5. showe1966

    showe1966 Member

    the contents of /etc/apache2/mods-available/jk.conf

    JkWorkersFile /opt/apache-tomcat/conf/
    JkShmFile /var/log/httpd/mod_jk.shm
    JkLogFile /opt/apache-tomcat/logs/mod_jk.log
    JkLogLevel warn
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    JkMountFile /opt/apache-tomcat/conf/
    JkRequestLogFormat "%w %V %T"
  6. showe1966

    showe1966 Member

    now I am also starting to understand what is going on...

    I have just gone through another 3 days trying to set up mod_jk with apache2 and tomcat on another server, so I am now starting to understand what is actually occuring.

    I am not working using open java or the ubuntu tomcat package, because my software developer prefers to put the webapps and configuration files for tomcat and mod_jk in a separate directory to those for apache .
    This makes a lot of sense, as you really want to configure tomcat and mod_jk each time you install a new version of tomcat, rather than configuring it each time you install a new version of apache.

    Here is what i did.

    NB My versions of tomcat and java are old and you probably want to be using newer ones.
    I am using older versions as my webapp is based on these software versions for the moment.

    I have changed my real website address to here.

    install java (I downloaded it from the sun website)

    install ispconfig.

    messgaes i got during ispconfig install:-

    Warning: DocumentRoot [/var/www/web1/web] does not exist
    Warning: DocumentRoot [/var/www/web1/web] does not exist
    Syntax error on line 83 of /etc/apache2/vhosts/Vhosts_ispconfig.conf:
    SSLCertificateFile: file '/var/www/web1/ssl/' does not exist or is empty
    * Stopping Postfix Mail Transport Agent postfix [ OK ]
    * Starting Postfix Mail Transport Agent postfix [ OK ]
    * Stopping ftp server proftpd [ OK ]
    * Starting ftp server proftpd - setting default address to
    [ OK ]
    Starting ISPConfig system...
    /root/ispconfig/httpd/bin/apachectl startssl: httpd started
    ISPConfig system is now up and running!

    the install went OK

    after install:-
    -login at as admin with password admin and change the password
    -click on the top tab MANAGEMENT
    -click on server in the directory tree
    set up dns servers to my dns servers which are:-

    also clicked on "default mx record"

    click on >isp manager > new client
    enter title for client:example
    enter first name foo
    enter last name bar

    Click on "New site"
    Hostname: www
    IP Address: 88.xx.xx.yy
    Create DNS: n
    Create DNS-MX: n
    Space MB: -1
    Traffic MB: -1
    Traffic Exceedance: notify
    Max. User: -1
    Max. Domain: -1
    Shell Access: n
    CGI Scripts: n
    Standard CGIs: n
    PHP Scripts: n
    PHP Safe Mode: n
    SSI: y
    FTP Access: y
    MySQL: n
    Number of Databases:
    SSL: y
    Anonymous FTP: n
    Anon. FTP MB: n
    WAP: n
    Individual Error Pages: n
    Mailuser Login: y
    after created site,
    modified client login and password

    click again on "your website"

    >create new user
    realname : your name
    e_mail address: [email protected]
    username: web1_name
    password xxxxxxxxxxxxxx
    administrator y

    Now it is necessary to create an ssl certificate for the website that has been created, otherwise ssl won't work properly :-

    click on the name of the website you just created in the directory tree
    click on the "ssl" tab

    Fill in the info in the top half of the box with your info, and put in the number of days the certificate should be valid for.

    In the button "action" select "create certificate".
    Click on save.
    Log out of the admin application and log back in again.
    go back to the same location as before, and both of the panels should be filled with the new ssl certificates.

    Now, you should find it possible to go to as well as and see the blue and white ispconfig default page.

    Now I have to do the following things:-

    1. Get tomcat working
    2. Get mod_jk working

    Check java is installed OK:-

    /usr/java/jdk/bin/java -version
    java version "1.6.0_05"
    Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
    Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)

    OK It's working

    Install tomcat:-

    copy from
    4.downloaded apache-tomcat-6.0.14.tar.gz to server
    directory /usr/local/src
    tar -xvxf apache-tomcat-6.0.14.tar.gz
    mv apache-tomcat-6.0.14 /opt
    cd /opt
    NB the location of apache-tomcat directory is referred to as "CATALINA_HOME"
    ln -s apache-tomcat-6.0.14 apache-tomcat
    (This link allows you to switch tomcat versions easily).

    5.set catalina home variable in the files /etc/profile and /root/.bashrc
    by adding the line:
    export CATALINA_HOME

    Mod jk was not installed
    so, use apt to install modjk:-

    apt-get install libapache2-mod-jk

    Checked that was in the directory /usr/lib/apache2/modules

    * Create a file by the name “” in /opt/apache-tomcat/conf/ directory:-

    * Create a file by the name “” in /opt/apache-tomcat/conf/ directory.
    This file is used instead of the jkload statement in the to give more flexibility in the case of multiple webapps. Note you have to subsitute the name of your webapps in this file:-

    * Edit the file by the name “jk.conf” in /etc/apache2/mods-available/ directory:-

    # Where to find
    JkWorkersFile /opt/apache-tomcat/conf/
    JkShmFile /var/log/httpd/mod_jk.shm
    # Where to put jk logs
    JkLogFile /opt/apache-tomcat/logs/mod_jk.log
    # Set the jk log level [debug/error/info]
    JkLogLevel warn
    # Select the log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    #specify the location of the jkmount file
    JkMountFile /opt/apache-tomcat/conf/
    # set the request format
    JkRequestLogFormat "%w %V %T"
    # JkOptions indicate to send SSL KEY SIZE,
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

    If the mod has been enabled using the debian a2enmod command , the above file will be appended to the apache2.conf file and then loaded by the following two commands that should be present in the apache2.conf file:-

    # Include module configuration:
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf

    As you can see, apache loads any files ending with .load first and .conf after, in /etc/apache2/mods-enabled/.

    All a2enmod does is create links from the directory mods-enables to the relevant .load and .conf files in the directory mods-available

    so, basically issue the commands

    the system should then tell you jk has been enabled and the relevant files should have been set up.

    Set up the server.xml file as shown:-

    copy of my /opt/apache-tomcat/server.xml file:-

    <?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

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

    <!--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
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users
    <Resource name="UserDatabase" auth="Container"
    description="User database that can be updated and saved"
    pathname="conf/tomcat-users.xml" />

    <!-- 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"
    redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <Connector executor="tomcatThreadPool"
    port="8080" protocol="HTTP/1.1"
    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="Standalone" 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"/>

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

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


    set up a script to start tomcat automatically:-

    touch /etc/init.d/tomcat

    vi /etc/init.d/tomcat and add:-

    #description: Starts Tomcat
    #processname: tomcat
    export CATALINA_HOME=/opt/apache-tomcat
    export JAVA_HOME=/usr/java/jdk
    $CATALINA_HOME/bin/ $*

    make sure it's executable:-
    chmod +x /etc/init.d/tomcat
    added to runlevel:
    update-rc.d tomcat defaults
    Adding system startup for /etc/init.d/tomcat ...
    /etc/rc0.d/K20tomcat -> ../init.d/tomcat
    /etc/rc1.d/K20tomcat -> ../init.d/tomcat
    /etc/rc6.d/K20tomcat -> ../init.d/tomcat
    /etc/rc2.d/S20tomcat -> ../init.d/tomcat
    /etc/rc3.d/S20tomcat -> ../init.d/tomcat
    /etc/rc4.d/S20tomcat -> ../init.d/tomcat
    /etc/rc5.d/S20tomcat -> ../init.d/tomcat

    To check if the tomcat server is working stand-alone, install the text-based browser lynx:-

    apt-get install lynx

    then type:-

    lynx http://localhost:8080

    To check if tomcat is working via apache, type:-

    lynx http://localhost/server-status

    You can apparently set up the system so as it will only allow access to your webapps via https by editing the web.xml file.
    However, I don't know how to do this yet, so this setup runs both stand-alone on port 8080 and via port 443 and https, which is a bit pointless really.

Share This Page