日期:2014-05-16 浏览次数:20705 次
一直在找讓tomcat并且加載到 linux服務中的方法,有的使用wrapper,我暫時還沒找到這種安裝的方法。看tomcat DOC文檔發現JSVC可以做到,即刻實踐,下面給自己做一下總結——
1、JDK和Tomcat的安裝這里就略過了
?
2、创建用户:
#groupadd tomcat
#useradd -s /sbin/nologin -g tomcat tomcat
?
3.修改目录所有者:
#chown -R tomcat:tomcat /usr/local/tomcat5.5
?
4、安装jsvc
#cd /usr/local/tomcat/bin
#tar xvfz jsvc.tar.gz
#cd jsvc-src
#sh support/buildconf.sh
#chmod 755 configure
#./configure --with-java=/usr/local/java????? (改成你的JDK的位置)
#make
注:我在執行./configure --with-java=/usr/local/java?的過程中,產生"configure: error:no acceptable C compiler found in $PATH "這樣的錯誤提示,發現是沒有安裝C編譯器,于是執行“yum install gcc”安裝了gcc,之后重新執行./configure --with-java=/usr/local/java?就Ok了
?
5、修改启动文件
#vi ./native/Tomcat5.sh
改成如下内容:
#
# chkconfig: 345 87 13
# description: Tomcat Daemon
# processname: jsvc
# pidfile: /var/run/jsvc.pid
# config:
#
# Source function library.
# . /etc/rc.d/init.d/functions
#
# prog=tomcat
#
# 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"/>
#
# You need a developement version of Tomcat (Apache Tomcat/4.1-dev)
#
# Adapt the following lines to your configuration
#!/bin/sh
##############################################################################
#
# 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/java/jdk1.5.0.12
CATALINA_HOME=/usr/local/tomcat5.5
DAEMON_HOME=/usr/local/tomcat5.5/bin
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/tomcat5.5
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/src/jsvc \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Dcatalina.base=$CATALINA_BASE \
-Djava.io.tmpdir=$TMP_DIR \
-wait 10 \
-pidfile $PID_FILE \
-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.
#-deb