Configure Tomcat startup in Linux and configure Tomcat startup in Linux

Source: Internet
Author: User
Tags apache tomcat

Tomcat startup can be implemented with built-in jsvc:
Jsvc was supposed to download the http://jakarta.apache.org from the commons-daemon-1.0-Alpha/, but tomcat has brought a, In the tomcat/bindirectory has a jsvc.tar.gz unzip, compile:
# Tar-xzvf jsvc.tar.gz
# Cd jsvc-Src
Run
# Sh support/buildconf. Sh
#./Configure -- With-Java =/usr/Java
# Make
(Note: jsvc in Tomcat-5.0.18 Source code There is a low-level error-missing a semicolon will cause compilation to fail. You can add this semicolon on your own)
Tomcat's own jsvc-src/native directory contains two scripts tomcat. SH and tomcat 5.sh, which can be used as scripts for starting and stopping tomcat. I will slightly modify Tomcat 5.sh. The file is as follows:
Code :
^ ^
#! /Bin/sh
#
# STARTUP script for tomcat5
#
# 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
# Set your own Parameters
Java_home =/usr/local/j2sdk1.4.2-04
Catalina_home =/usr/local/jakarta-tomcat-5.0.19
Daemon_home = $ catalina_home/bin
# You need to set a permission in the system
# Running by the user, which is safer
Tomcat_user = tomcat5
Tmp_dir =/var/tmp
Catalina_opts =
Classpath = \
$ Java_home/lib/tools. jar :\
$ Catalina_home/bin/commons-daemon.jar :\
$ Catalina_home/bin/Bootstrap. Jar
Start (){
Echo-N $ "Starting $ prog :"
#
# Start Tomcat
#
$ Daemon_home/jsvc-src/jsvc \
-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 \
Retval =$?
[$ Retval = 0] & Touch/var/lock/subsys/jsvc
[$ Retval = 0] & echo_success | echo_failure
Echo
Return $ retval
}
Stop (){
Echo-N $ "Stopping $ prog :"
#
# Stop Tomcat
#
PID = 'cat/var/run/jsvc. PID'
Kill $ PID
Retval =$?
[$ Retval = 0] & RM/var/lock/subsys/jsvc
[$ Retval = 0] & echo_success | echo_failure
Echo
Return $ retval
}
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Restart | RELOAD)
Stop
Start
;;
*)
Echo "usage $0 start/stop"
Exit 1 ;;
Esac
^ ^
Save the code as/etc/rc. d/init. d/tomcat, and then run
# Chkconfig -- add Tomcat
Use -- list to check whether the system has a tomcat Startup File.
# Ckhconfig -- list
Tomcat is automatically started with the system. This script is automatically started in runlevel 3/4/5 mode. Note that this script is created for Tomcat 5. If you use Tomcat 4, you need to modify it based on another tomcat. Sh file.

=== Loo, practical summary ===
Jmw uses Tomcat 4.1 and does not have its own jsvc. You need to download the jsvc and then follow the steps above.
Note that the tomcat_user = tomcat5 mentioned above must be a system user and have the write permission on the $ tomcat_home/conf directory to start Tomcat, you need to create a temporary tomcat-user.xm.new file under this folder when starting tomcat. you can use $ tomcat_home/logs/Catalina. view specific logs. at the same time, because the machine is installed with Oracle and configured to start at boot. when oracle is started, the tnslsnr process will occupy port 8080 (do not know how to modify), leading to the default Tomcat startup failure. A good command is found in the process of solving the problem:
1. Check the port usage for the current day: netstat-
2. Check that the process occupies the port: lsof-I: 8080 (8080 indicates the port to be viewed) based on the port number)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.