Tomcat 6.0.20/Tomcat Connectors JK 1.2.28

Tomcat 6.0.20

# cd /usr/local/libexec
# gzip -dc apache-tomcat-6.0.20.tar.gz | tar xf -
# mv apache-tomcat-6.0.20 apache-tomcat

Tomcat Connectors JK 1.2.28

% tomcat-connectors-1.2.28-src.tar.gz
% cd tomcat-connectors-1.2.28/native

Apache 2.2の場合

以下のsetup.shスクリプトを実行します。

#!/bin/sh

if [ $# -eq 1 ]; then
        . ../../setup-pre.sh $1
else
        . ../../setup-pre.sh
fi

./configure \
  --with-apxs=/usr/local/sbin/$ISA/apxs \
  --with-java-home=/usr/java
% ./setup.sh [sparcv8plus or sparcv9 or i386 or amd64]
% gmake
# gmake install

Solaris付属のApache 2.0の場合

以下のsetup.shスクリプトを実行します。

#!/bin/sh

if [ $# -eq 1 ]; then
        . ../../setup-pre.sh $1
else
        . ../../setup-pre.sh
fi

./configure \
  --with-apxs=/usr/apache2/bin/apxs \
  --with-java-home=/usr/java
% ./setup.sh sparcv8plus

Solaris付属のlibtoolを使うようなMakefileができあがりますが、 そのままではうまくコンパイルできないので、できあがったMakefile のlibtoolのパスを修正します。

- LIBTOOL = /bin/bash /var/apache2/build/libtool --silent
+ LIBTOOL = /bin/bash /usr/local/share/apache/build-1/libtool --silent

makeしてできあがったモジュールをコピーします。

% gmake
# cp apache-2.0/mod_jk.so /usr/apache2/libexec

起動

/etc/apache22/httpd.confに以下を追加します。

LoadModule jk_module libexec/apache/sparcv9/mod_jk.so

<IfModule mod_jk.c>
        JkWorkersFile /etc/apache22/workers.properties
        JkLogFile  /var/log/jk.log
        JkShmFile  /var/log/jk-runtime-status
        JkLogLevel error

        JkMount /*.jsp localhost
        JkMount /servlet/* localhost
        JkMount /examples/* localhost
</IfModule>

/etc/apache22/workers.properties

worker.list=localhost

worker.localhost.port=8009
worker.localhost.host=localhost
worker.localhost.type=ajp13
worker.localhost.lbfactor=1

#workers.java_home=/usr/java
workers.tomcat_home=/usr/local/libexec/apache-tomcat

manifest: tomcat.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
	  "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='tomcat'>

<service name='application/tomcat' type='service' version='1'>

    <instance name='default' enabled='false'>
       <dependency name='network'
           grouping='require_all'
           restart_on='error'
           type='service'>
           <service_fmri value='svc:/milestone/network:default'/>
       </dependency>

       <dependency name='filesystem-local'
           grouping='require_all'
           restart_on='none'
           type='service'>
           <service_fmri
               value='svc:/system/filesystem/local:default'/>
       </dependency>

       <dependency name='autofs'
           grouping='optional_all'
           restart_on='error'
           type='service'>
           <service_fmri
               value='svc:/system/filesystem/autofs:default'/>
       </dependency>

       <exec_method
           type='method'
           name='start'
           exec='/lib/svc/method/tomcat %m'
           timeout_seconds='60'>
           <method_context>
               <method_credential
                   user='root' group='root'
                   privileges='basic,!proc_session,!proc_info,!file_link_any,net_privaddr'
                   />
           </method_context>
      </exec_method>

      <exec_method
           type='method'
           name='stop'
           exec='/lib/svc/method/tomcat %m'
           timeout_seconds='60'>
           <method_context />
      </exec_method>

       <exec_method
           type='method'
           name='refresh'
           exec='/lib/svc/method/tomcat %m'
           timeout_seconds='60'>
           <method_context />
      </exec_method>

        <property_group name='startd' type='framework'>
            <propval name='ignore_error' type='astring'
                     value='core,signal' />
        </property_group>
        <property_group name='tomcat' type='application'>
            <stability value='Evolving' />
        </property_group>

    </instance>

    <stability value='Evolving' />
    <template>
        <common_name>
            <loctext xml:lang='C'>
                Apache Tomcat Servlet Container
            </loctext>
        </common_name>
        <documentation>
            <doc_link name='apache.org'
                uri='http://tomcat.apache.org/tomcat-6.0-doc/' />
        </documentation>
    </template>
</service>

</service_bundle>

method: tomcat

#!/sbin/sh
#

. /lib/svc/share/smf_include.sh

JAVA_HOME=/usr/java
TOMCAT_HOME=/usr/local/libexec/apache-tomcat
CONF_DIR=${TOMCAT_HOME}/conf
CATALINA_PID=${TOMCAT_HOME}/logs/catalina.pid
if [ "x$JAVA_HOME" = "x" ]; then
    echo "JAVA_HOME not set properly. Set the JAVA_HOME environment
variable"
    exit 96; # SMF_EXIT_ERR_CONFIG
fi

if test ! -x "$JAVA_HOME/bin/java"; then
    echo "JAVA_HOME is set but $JAVA_HOME/bin/java doesn't exist."
    exit 96; # SMF_EXIT_ERR_CONFIG
fi
export CATALINA_PID
export JAVA_HOME

start()
{
    /bin/rm -f ${CATALINA_PID}
    exec ${TOMCAT_HOME}/bin/startup.sh
}

stop()
{
    ${TOMCAT_HOME}/bin/shutdown.sh
    sleep 3;
    kill -0 `cat ${CATALINA_PID}` >/dev/null 2>&1
    if [ $? -eq 0 ] ; then
        # Process still alive. Use force method
        ${TOMCAT_HOME}/bin/shutdown.sh -force
    fi
    /bin/rm -f ${CATALINA_PID}
}

[ ! -d ${CONF_DIR} ] &&  exit $SMF_EXIT_ERR_CONFIG

case "$1" in
    start)
        start
        ;;
    refresh)
        stop
        start
        ;;
    stop)
        stop
        ;;
    *)
        echo "Usage: $0 {start|stop|refresh}"
        exit 1
        ;;
esac

manifestとmethodを登録します。

# cp tomcat /lib/svc/method/
# chown root:bin /lib/svc/method/tomcat
# chmod 555 /lib/svc/method/tomcat
# cp tomcat.xml /var/svc/manifest/network/
# chown root:sys /var/svc/manifest/network/tomcat.xml
# chmod 444 /var/svc/manifest/network/tomcat.xml
# /usr/sbin/svccfg validate /var/svc/manifest/network/tomcat.xml
# /usr/sbin/svccfg -v import /var/svc/manifest/network/tomcat.xml

サービスを有効化します。

# svcadm enable network/tomcat:default