[iyunv@t246 bin]# cd /usr/java/tomcat/bin
[iyunv@t246 bin]# tar zxvf commons-daemon-native.tar.gz
[iyunv@t246 bin]# cd commons-daemon-1.0.14-native-src/unix
[iyunv@t246 unix]# ./configure
[iyunv@t246 unix]# make
[iyunv@t246 unix]# cp jsvc ../..
三、修改daemon.sh脚本
#!/bin/sh
# 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.
#
# -----------------------------------------------------------------------------
# Commons Daemon wrapper script.
#
# $Id: daemon.sh 1202058 2011-11-15 06:37:12Z mturk $
# -----------------------------------------------------------------------------
#
#ADD for jsvc 1.0.14 段错误
if [ -z $LD_LIBRARY_PATH ]; then
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
fi
JAVA_HOME=/usr/java/default #添加
CATALINA_HOME=/usr/java/tomcat #添加
CATALINA_BASE=/usr/java/tomcat #添加
DAEMON_HOME=/usr/java/tomcat/bin #添加
TOMCAT_USER=tomcat #添加
# resolve links - $0 may be a softlink
ARG0="$0"
while [ -h "$ARG0" ]; do
ls=`ls -ld "$ARG0"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
ARG0="$link"
else
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
以下省略
增加注释为“添加”的换变量
四、修改启动脚本
现在tomcat的二进制发行包里面有系统服务启动脚本的模版了,需要自己编写
[iyunv@t246 ~]# cat /etc/init.d/tomcat
#!/bin/bash
#
# Tomcat daemon.sh Startup script for the Tomcat Server
#
# chkconfig: 235 98 98
# description: Tomcat 7 server
# processname: java
# Source function library.
. /etc/rc.d/init.d/functions
#Tomcat Daemon path
daemon_path=/usr/java/tomcat/bin
# See how we were called.
case "$1" in
run)
echo "Start Tomcat without detaching from console..."
$daemon_path/daemon.sh run
;;
start)
echo "Start Tomcat..."
$daemon_path/daemon.sh start
;;
stop)
echo "Stop Tomcat..."
$daemon_path/daemon.sh stop
;;
version)
echo "What version of commons daemon and Tomcat are you running?"
$daemon_path/daemon.sh version
;;
*)
echo "Usage: $0 {run|start|stop|version}"
exit 1
;;
esac
exit 0