Linux, Tomcat starts with the system configuration

2010-12-14  来源:本站原创  分类:OS  人气:116 

1 install jdk, in the / etc / profile to configure java environment variables.

export JAVA_HOME = / usr/local/jdk1.5.0_09

export PATH = $ JAVA_HOME / bin: $ PATH

export CLASSPATH =.: $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar

2 Installing tomcat. Three lines from the script environment variable profile file to / etc / rc.d / rc.local file at the end. Because only the user profile file when logging in will perform. The rc.local is executed automatically after system startup.
The end of the rc.local file to set the Java environment variables added after the script command to start tomcat:
/ Usr/local/tomcat5.5/bin/startup.sh

under linux tomcat startup script with the system automatically

#! / Bin / sh
#
# Chkconfig: 345 86 14
# Description: manager tomcat
#
# Filename: / etc / rc.d / init.d / tomcat5
#

javaDir = `ls / usr / java`
for java in $ javaDir
do
export JAVA_HOME = "/ usr / java / $ {java}"
done

export TOMCAT_HOME = "/ usr/tomcat5"

case $ 1 in
start) $ TOMCAT_HOME / bin / startup.sh
;;
stop) $ TOMCAT_HOME / bin / shutdown.sh
;;
restart) $ TOMCAT_HOME / bin / shutdown.sh
$ TOMCAT_HOME / bin / startup.sh
;;
*) Echo "Usage: $ 0 {start | stop | restart}"
;;
esac
exit 0

Tomcat as a service since the launch of a Linux system set up

I. The simplest way is the easiest way that comes through the Tomcat startup.sh to start automatically, edit / etc / rc.d / rc.local, add:
export JDK_HOME = / usr / local / jdk
export JAVA_HOME = / usr / local / jdk
/ Usr / local / tomcat / bin / startup.sh

II. Complex and professional approach to the first method can not specify start the Tomcat service users, there are security risks, while the system is shut down automatically when not to stop the service. Under Linux, Tomcat as a daemon to start and stop, this must be by means of project commons-daemon in jsvc tools. After Tomcat installation with this tool on the source $ CATALINA_HOME / bin / jsvc.tar.gz. First install the tools:
# Tar zxvf jsvc.tar.gz
# Cd jsvc-src
# Chmod + x configure
#. / Configure - with-java = / usr / jdk
# Make
#. / Jsvc-help / / test

Can not be used after chkconfig - add tomcat set to start automatically, displays an error message: service tomcat does not support chkconfig, you need to modify the script $ CATALINA_HOME / bin / jsvc-src / native / Tomcat.sh, and cp to / etc / rc.d / init.d. I start the script as follows (the middle there have been several problems, script problems are found, they must be careful):

#! / 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:
#
# <! - Define a non-SSL HTTP/1.1 Connector on port 80 ->
# <Connector className = "org.apache.catalina.connector.http.HttpConnector"
# 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

JAVA_HOME = / usr / local / jdk
CATALINA_HOME = / usr / local / tomcat
DAEMON_HOME = $ CATALINA_HOME / bin / jsvc-src
TOMCAT_USER = tomcat
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 \
-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

This will be done a (certain path, user settings need to modify according to their specific environment). May need to use chown tomcat tomcat and chmod + x tomcat change owner and permissions to execute

相关文章
  • Linux, Tomcat starts with the system configuration 2010-12-14

    1 install jdk, in the / etc / profile to configure java environment variables. export JAVA_HOME = / usr/local/jdk1.5.0_09 export PATH = $ JAVA_HOME / bin: $ PATH export CLASSPATH =.: $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar 2 Install

  • Linux common commands to view system configuration 2010-12-03

    Reprinted from the depth of VPS [http://www.deepvps.com] System # Uname-a # See kernel / operating system / CPU Information # Head-n 1 / etc / issue # check the operating system version # Cat / proc / cpuinfo # View CPU Information Check the computer

  • (R) Linux common commands to view system configuration 2011-02-23

    Original from http://qa.taobao.com/?p=2273 uname-a view the kernel / operating system / CPU Information head-n 1 / etc / issue Check operating system version cat / proc / cpuinfo View CPU Information Check the computer name hostname lspci-tv list all

  • linux common commands to view system 2010-10-25

    Linux common commands to view system configuration Quote # Uname-a # See kernel / operating system / CPU Information # Head-n 1 / etc / issue # check the operating system version # Cat / proc / cpuinfo # View CPU Information Check the computer name #

  • Linux, start with the system configuration of Tomcat 2010-12-14

    1. Install jdk, in the / etc / profile environment variables to configure java. export JAVA_HOME = / usr/local/jdk1.5.0_09 export PATH = $ JAVA_HOME / bin: $ PATH export CLASSPATH =.: $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar 2. Insta

  • Linux system configuration since the start tomcat5 2010-12-03

    Department of Linux systems in general under the tomcat from the start in two configurations: [1] code to write directly to the start / etc / rc.local inside. Tomcat root privileges in this way will be run, there are security risks, recommended the s

  • Linux system configuration since the launch of tomcat5 2010-12-03

    Department of Linux systems in general under the tomcat from the start, there are two configurations: [1] directly to the boot code written to / etc / rc.local inside. Tomcat in this way will be running as root, there are security risks, recommended

  • Installation and configuration under Linux tomcat 2011-03-16

    Installation and configuration under Linux tomcat (1), the official website to download Apache apache-tomcat-6.0.29.tar.gz file. (2), extract and unpack Enter the command: tar-zxvf apache-tomcat-6.0.29.tar.gz In the directory under apache-tomcat-6.0.

  • linux file system configuration files 2011-06-10

    Blue file ---------- directory White paper ---------- General documents, such as text files, configuration files, source files, etc. ---------- Blue file link file, mainly documents created using the ln command Green ---------- executable files, exec

  • Linux, Tomcat and the Apache Web server integration 2010-12-30

    Linux, Tomcat and the Apache Web server consolidation 1 Introduction Web-based technology, Internet / Intranet in recent years has been widely used, Intranet is a TCP / IP protocol-based, enterprise Web as the core network, users low-cost, easy to us

  • linux garbled solve and modify the configuration file directly into the command line interface 2011-03-03

    [B] for domestic Linux users, often troubling question is: The system often needs to display Chinese, when they display become garbled, but for some reason, the English interface, the system needs time, but could not normally enter the system and sho

  • oracle - Linux - Unix under the ODBC installation. Configuration and Programming 2010-04-12

    Transfer from: http://linux.sheup.com/linux/linux3962.htm Linux / Unix under the ODBC installation, configuration and programming 2004-04-23 15:18 pm From: Linux documents are shown: Www.8s8s.coM Address: unknown Content: ODBC principle Linux / Unix

  • (Linux Essay) VirtualBox virtual machine system resolution settings problem 2010-06-28

    (Linux Essay) VirtualBox virtual machine system resolution settings problem Problem description: The next few days to play Sun's open source virtual machine software, VirtualBox, the problems encountered in the middle of this to be a summary. Virtual

  • centos5.3 System Configuration DNS server configuration Xiangjie 2010-07-13

    Transfer from: http://hi.baidu.com/waibaohuo/blog/item/cc99d611f2efa18a6438db42.html [Original] centos5.3 System Configuration DNS server configuration Xiangjie 2009-10-22 12:03 Article excerpts of some users of the relevant information in this thank

  • debian system configuration file description 2010-07-30

    In the Debian system, there are a lot of configuration files, these profiles are important, control systems and applications running. The following records the storage location of these profiles, roles and configuration parameters, so that we can qui

  • The next generation of software development model - the system configuration generated visualization 2009-06-15

    With the technological progress and social development, the application of increasingly complex systems, system upgrades have become routine. Development system because of the use of technology is too old, and now the technical compatibility bad, if

  • Based on apache's tomcat load balancing and clustering configuration 2010-05-27

    Based on apache's tomcat load balancing and clustering configuration 1] download httpd-2.2.15-win32-x86-no_ssl.msi Web server 32-bit Windows zip tomcat mod_jk-1.2.30-httpd-2.2.3.so Apache / Tomcat, IIS module used to connect the background to support

  • linux tomcat start command 2010-05-28

    1) execute the command: tar-zxvf jakarta-Linux tomcat-5.0.19.tar.g unpack directory jakarta-Linux tomcat-5.0.19 2) Set environment variables vi / etc / profile add the following contents: Linux tomcat_HOME = foo / Linux tomcat export Linux tomcat_HOM

  • Add the contents of the Magento System Configuration 2010-06-13

    Custom Magento System Configuration Magento is a strong reason why, in part because it has a very strong background (Admin's System Config section) configuration. It allows developers to add form elements through the Magento system and the user can c

  • Premium Magento System Configuration 2010-06-13

    In Depth Magento System Configuration The previous section describes the Magento's system configuration, this section will explore in depth the different elements of different labels field specific applications <fields> <!-- ... ---> <field