Keyword: Linux jsvc Tomcat Service
I have been searching for methods for Tomcat and adding them to the Linux server. Some of them use wrapper and I haven't found this security method yet. Check the Tomcat DOC file and find that jsvc can be done. implement it immediately. Let's make a summary for myself --
1. JDK and tomcat have been installed.
2. Create a user:
# Groupadd Tomcat
# Useradd-S/sbin/nologin-G Tomcat
3. Modify the directory owner:
# Chown-r Tomcat: tomcat/usr/local/tomcat5.5
4. Install 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 (change to your JDK location)
# Make
Note: I am doing this. in the process of/configure -- With-Java =/usr/local/Java, the error message "Configure: Error: no acceptable C compiler found in $ path" is generated, it is found that there is no security C compiler, so the line "yum install GCC" has installed GCC, and then re-installed the line. /configure -- With-Java =/usr/local/Java is OK
5. Modify the Startup File
# Vi./native/tomcat5.sh
Change to the following content:
#
# 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" type = "codeph" text = "codeph"/>
#
# 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 before t in compliance with the license.
# You may obtain a copy of the license
#
# 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" type = "codeph" text = "codeph"/>
#
# 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.
#-Debug/
Exit $?
;;
Stop)
#
# Stop Tomcat
#
$ Daemon_home/src/jsvc/
-Stop/
-Pidfile $ pid_file/
Org. Apache. Catalina. startup. Bootstrap
Exit $?
;;
*)
Echo "Usage: $0 start/stop"
Exit 1 ;;
Esac
6. Copy the Startup File
# Cp./native/tomcat5.sh/etc/init. d/tomcat5
# Chmod-C 777/etc/init. d/tomcat5
7. Add a service
# Chkconfig -- add tomcat5
# Chkconfig -- level 345 tomcat5 on
8. Complete. Start the service.
# Service tomcat5 start
Restart the system and Tomcat will start automatically.
Note --
1. The path in the tomcat5.sh Startup file must be correct, and the comments before the file cannot be deleted; otherwise, the service cannot be added.
2. The owner of the tomcat installation directory must modify (# chown-r Tomcat: tomcat/usr/Java/tomcat5.5)
Otherwise, an error message (Java hotspot (TM) Client VM warning: can't detect initial thread stack location-find_vma failed) is returned.
ZZ: http://wenson.javaeye.com/blog/153771
When the files are installed according to the example, the corresponding file path is modified. When the # chkconfig -- add tomcat5 command is executed, it is displayed that Tomcat does not support chkconfig and does not know why, the Tomcat and jdk I use are 6.0 and 1.6 respectively!