/etc/init.d
aufgerufen werden. Hierzu verwendet man jsvr aus dem commons-daemons projekt
(Auch jakarta). Das ist soweit in der vorbereitet, dass man nur noch wenig zu tun hat
damit das läuft.
cd /usr/local/java/tomcat/bin
tar xvzf jsvc.tar.gz
cd jsvc-src
autoconf
./configure --with-java=/usr/local/java/java
make
cp jsvc ..
cd ..
Anmerkung:
Wenn man sowas bekommt:
linux:/usr/local/java/tomcat/bin/jsvc-src # autoconf
Dann muss man das Paket "autoconf" installieren.
-bash: autoconf: command not found
Jetzt muss nur noch ein Startskript in /etc/init.d angelegt werden, dass das jsvc tool
aufruft, dazu wird schon ein Skript mitgeliefert
(/usr/local/java/tomcat/bin/jsvc-src/native/Tomcat5.sh), das jedoch noch
angepasst werden muss. Mein angepasstes Skript habe ich unter /etc/init.d/tomcat5
abgelegt sieht so aus:
#!/bin/sh
#
# /etc/init.d/tomcat
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network
# X-UnitedLinux-Should-Start: $named
# Required-Stop: $network
# X-UnitedLinux-Should-Stop: $named
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: jakarta tomcat daemon
# Description: Start tomcat, browser can reach the
# tomcat server.
### END INIT INFO
#
##############################################################################
#
# Copyright 2004 The Apache Software Foundation.
#
# Licensed 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.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#
#
# port="80" minProcessors="5" maxProcessors="75"
# enableLookups="true" redirectPort="8443"
# acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/local/java/java
CATALINA_HOME=/usr/local/java/tomcat
DAEMON_BIN=/usr/local/java/tomcat/bin/jsvc
TOMCAT_USER=root
TMP_DIR=/var/tmp
CATALINA_OPTS=-Xmx300m
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_BIN \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Djava.io.tmpdir=$TMP_DIR \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose \
# To get a debug of jsvc.
#-debug \
;;
stop)
#
# Stop Tomcat
#
PID=`cat /var/run/jsvc.pid`
kill $PID
;;
*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac
/etc/init.d/tomcat5
ausführbar sein und wir müssen dem System bescheid sagen.
chmod +x /etc/init.d/tomcat5
inserv tomcat5