[root@joyway install]# ls -lrt
total 1280156
-rw-r--r-- 1 root root 472760320 Jan 20 16:09 mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 9390469 Jan 23 11:00 apache-tomcat-8.0.48.tar.gz
-rw-r--r-- 1 root root 187157685 Jan 29 16:12 jdk-8u152-linux-x64.tar.gz
-rw-r--r-- 1 root root 641555814 Mar 4 13:44 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x 2 root root 4096 Mar 5 13:55 mysql-5.7.16-linux-glibc2.5-x86_64
1.查看Linux的版本:
[root@joyway install]# uname -r
3.10.0-693.2.2.el7.x86_64
2.解壓jdk和Tomcat文件:
[root@joyway install]# tar -xzf jdk-8u152-linux-x64.tar.gz
[root@joyway install]# tar -xzf apache-tomcat-8.0.48.tar.gz
解壓完畢:
[root@joyway install]# ls -lrt
total 1280164
drwxrwxrwx 8 root root 4096 Nov 9 09:33 jdk1.8.0_152
-rw-r--r-- 1 root root 472760320 Jan 20 16:09 mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 9390469 Jan 23 11:00 apache-tomcat-8.0.48.tar.gz
-rw-r--r-- 1 root root 187157685 Jan 29 16:12 jdk-8u152-linux-x64.tar.gz
-rw-r--r-- 1 root root 641555814 Mar 4 13:44 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x 2 root root 4096 Mar 5 13:55 mysql-5.7.16-linux-glibc2.5-x86_64
drwxr-xr-x 9 root root 4096 Mar 6 10:00 apache-tomcat-8.0.48
3.把jdk 的文件挪到 /application/jdk 下面
[root@joyway install]# mkdir -p /application/jdk
[root@joyway install]# mv jdk1.8.0_152 /application/jdk
[root@joyway install]# ll /application/jdk
total 4
drwxrwxrwx 8 root root 4096 Nov 9 09:33 jdk1.8.0_152
[root@joyway jdk]# ls -lrt
total 4
drwxrwxrwx 8 root root 4096 Nov 9 09:33 jdk1.8.0_152
[root@joyway jdk]# cd jdk1.8.0_152
[root@joyway jdk1.8.0_152]# mv * ../
[root@joyway jdk1.8.0_152]# cd ..
[root@joyway jdk]# ls -lrt
total 25960
-rwxrwxrwx 1 root root 63933 Sep 14 14:34 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rwxrwxrwx 1 root root 5202883 Sep 14 14:34 javafx-src.zip
-rwxrwxrwx 1 root root 159 Sep 14 17:24 README.html
-rwxrwxrwx 1 root root 40 Sep 14 17:24 LICENSE
-rwxrwxrwx 1 root root 3244 Sep 14 17:24 COPYRIGHT
-rwxrwxrwx 1 root root 21117451 Sep 14 17:24 src.zip
-rwxrwxrwx 1 root root 424 Sep 14 17:24 release
drwxrwxrwx 5 root root 4096 Nov 9 09:33 lib
drwxrwxrwx 3 root root 4096 Nov 9 09:33 include
drwxrwxrwx 4 root root 4096 Nov 9 09:33 db
drwxrwxrwx 5 root root 4096 Nov 9 09:33 man
drwxrwxrwx 5 root root 4096 Nov 9 09:33 jre
drwxrwxrwx 2 root root 4096 Nov 9 09:33 bin
-rwxrwxrwx 1 root root 145193 Nov 9 09:35 THIRDPARTYLICENSEREADME.txt
drwxrwxrwx 2 root root 4096 Mar 6 10:01 jdk1.8.0_152
[root@joyway jdk]# pwd
/application/jdk
[root@joyway jdk]# rm jdk1.8.0_152
rm: cannot remove 鈥榡dk1.8.0_152鈥 Is a directory
[root@joyway jdk]# rm -rf jdk1.8.0_152
4.在 /etc/profile 加入JAVA_HOME=/application/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
記得:source /etc/profile
[root@joyway install]# vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
fi
esac
}
if [ -x /usr/bin/id ]; then
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
unset -f pathmunge
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
JAVA_HOME=/application/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
"/etc/profile" 80L, 1986C written
[root@joyway install]#
[root@joyway install]#
[root@joyway install]# source /etc/profile
[root@joyway install]# java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
[root@joyway ~]# cd install
[root@joyway install]# ls -rlt
total 1280160
-rw-r--r-- 1 root root 472760320 Jan 20 16:09 mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 9390469 Jan 23 11:00 apache-tomcat-8.0.48.tar.gz
-rw-r--r-- 1 root root 187157685 Jan 29 16:12 jdk-8u152-linux-x64.tar.gz
-rw-r--r-- 1 root root 641555814 Mar 4 13:44 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x 2 root root 4096 Mar 5 13:55 mysql-5.7.16-linux-glibc2.5-x86_64
drwxr-xr-x 9 root root 4096 Mar 6 10:00 apache-tomcat-8.0.48
5.把Tomcat 移到 /application 目錄下面
[root@joyway install]# mv apache-tomcat-8.0.48 /application
[root@joyway application]# ls -lrt
total 8
drwxr-xr-x 9 root root 4096 Mar 6 10:00 apache-tomcat-8.0.48
drwxr-xr-x 8 root root 4096 Mar 6 10:02 jdk
[root@joyway application]# mv apache-tomcat-8.0.48 tomcat
[root@joyway application]# ls -lrt
total 8
drwxr-xr-x 9 root root 4096 Mar 6 10:00 tomcat
drwxr-xr-x 8 root root 4096 Mar 6 10:02 jdk
[root@joyway application]# cd tomcat
[root@joyway tomcat]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@joyway tomcat]# cd bin
6.解壓 commons-daemon-native.tar.gz
[root@joyway bin]# tar zxf commons-daemon-native.tar.gz
[root@joyway bin]# ls -lrt
total 836
-rw-r--r-- 1 root root 2026 Dec 1 00:29 version.bat
-rw-r--r-- 1 root root 4586 Dec 1 00:29 tool-wrapper.bat
-rw-r--r-- 1 root root 405109 Dec 1 00:29 tomcat-native.tar.gz
-rw-r--r-- 1 root root 48302 Dec 1 00:29 tomcat-juli.jar
-rw-r--r-- 1 root root 2022 Dec 1 00:29 startup.bat
-rw-r--r-- 1 root root 2020 Dec 1 00:29 shutdown.bat
-rw-r--r-- 1 root root 3574 Dec 1 00:29 setclasspath.bat
-rw-r--r-- 1 root root 2091 Dec 1 00:29 digest.bat
-rw-r--r-- 1 root root 2040 Dec 1 00:29 configtest.bat
-rw-r--r-- 1 root root 207125 Dec 1 00:29 commons-daemon-native.tar.gz
-rw-r--r-- 1 root root 25145 Dec 1 00:29 commons-daemon.jar
-rw-r--r-- 1 root root 15827 Dec 1 00:29 catalina.bat
-rw-r--r-- 1 root root 34630 Dec 1 00:29 bootstrap.jar
-rwxr-xr-x 1 root root 1908 Dec 1 00:29 version.sh
-rwxr-xr-x 1 root root 5495 Dec 1 00:29 tool-wrapper.sh
-rwxr-xr-x 1 root root 1904 Dec 1 00:29 startup.sh
-rwxr-xr-x 1 root root 1902 Dec 1 00:29 shutdown.sh
-rwxr-xr-x 1 root root 3680 Dec 1 00:29 setclasspath.sh
-rwxr-xr-x 1 root root 1965 Dec 1 00:29 digest.sh
-rwxr-xr-x 1 root root 8509 Dec 1 00:29 daemon.sh
-rwxr-xr-x 1 root root 1922 Dec 1 00:29 configtest.sh
-rwxr-xr-x 1 root root 23170 Dec 1 00:29 catalina.sh
-rw-r--r-- 1 root root 1647 Dec 1 00:30 catalina-tasks.xml
drwxr-xr-x 4 root root 4096 Mar 6 15:11 commons-daemon-1.1.0-native-src
[root@joyway bin]# cd commons-daemon-1.1.0-native-src
[root@joyway commons-daemon-1.1.0-native-src]# ls -lrt
total 32
-rw-rw-r-- 1 mysql mysql 11358 Feb 26 2005 LICENSE.txt
-rw-rw-r-- 1 mysql mysql 279 Nov 25 2011 README
-rw-rw-r-- 1 mysql mysql 175 Jul 8 2017 NOTICE.txt
-rw-rw-r-- 1 mysql mysql 1874 Nov 9 22:20 RELEASE-NOTES.txt
drwxrwxr-x 7 mysql mysql 4096 Nov 15 20:03 windows
drwxrwxr-x 5 mysql mysql 4096 Nov 15 20:03 unix
7.編譯 unix 下面的 configure
[root@joyway unix]# ./configure --with-java=/application/jdk
[root@joyway commons-daemon-1.1.0-native-src]# cd unix
[root@joyway unix]# ./configure --with-java=/application/jdk
*** Current host ***
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking cached host system type... ok
*** C-Language compilation tools ***
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ranlib... ranlib
checking for strip... strip
*** Host support ***
checking C flags dependant on host system type... ok
*** Java compilation tools ***
checking JAVA_HOME... /application/jdk
checking for JDK os include directory... linux
gcc flags added
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/capability.h usability... no
checking sys/capability.h presence... no
checking for sys/capability.h... no
configure: WARNING: cannot find headers for libcap
*** Writing output files ***
configure: creating ./config.status
config.status: creating Makefile
config.status: creating Makedefs
config.status: creating native/Makefile
*** All done ***
Now you can issue "make"
[root@joyway unix]# make
(cd native; make all)
make[1]: Entering directory `/application/tomcat/bin/commons-daemon-1.1.0-native-src/unix/native'
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c jsvc-unix.c -o jsvc-unix.o
jsvc-unix.c: In function 鈥[01mrun_controller鈥
jsvc-unix.c:1304:20: warning: assignment from incompatible pointer type [enabled by default]
act.sa_handler = controller;
^
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c arguments.c -o arguments.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c debug.c -o debug.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c dso-dlfcn.c -o dso-dlfcn.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c dso-dyld.c -o dso-dyld.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c help.c -o help.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c home.c -o home.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c java.c -o java.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c location.c -o location.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c replace.c -o replace.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c locks.c -o locks.o
gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/application/jdk/include -I/application/jdk/include/linux -c signals.c -o signals.o
ar cr libservice.a arguments.o debug.o dso-dlfcn.o dso-dyld.o help.o home.o java.o location.o replace.o locks.o signals.o
ranlib libservice.a
gcc jsvc-unix.o libservice.a -ldl -lpthread -o ../jsvc
make[1]: Leaving directory `/application/tomcat/bin/commons-daemon-1.1.0-native-src/unix/native'
[root@joyway unix]# ll jsvc
-rwxr-xr-x 1 root root 174304 Mar 6 15:12 jsvc
[root@localhost unix]# cp jsvc ../../
[root@localhost unix]#
root@joyway commons-daemon-1.1.0-native-src]# cd ..
[root@joyway bin]# ls -lrt
total 1008
-rw-r--r-- 1 root root 2026 Dec 1 00:29 version.bat
-rw-r--r-- 1 root root 4586 Dec 1 00:29 tool-wrapper.bat
-rw-r--r-- 1 root root 405109 Dec 1 00:29 tomcat-native.tar.gz
-rw-r--r-- 1 root root 48302 Dec 1 00:29 tomcat-juli.jar
-rw-r--r-- 1 root root 2022 Dec 1 00:29 startup.bat
-rw-r--r-- 1 root root 2020 Dec 1 00:29 shutdown.bat
-rw-r--r-- 1 root root 3574 Dec 1 00:29 setclasspath.bat
-rw-r--r-- 1 root root 2091 Dec 1 00:29 digest.bat
-rw-r--r-- 1 root root 2040 Dec 1 00:29 configtest.bat
-rw-r--r-- 1 root root 207125 Dec 1 00:29 commons-daemon-native.tar.gz
-rw-r--r-- 1 root root 25145 Dec 1 00:29 commons-daemon.jar
-rw-r--r-- 1 root root 15827 Dec 1 00:29 catalina.bat
-rw-r--r-- 1 root root 34630 Dec 1 00:29 bootstrap.jar
-rwxr-xr-x 1 root root 1908 Dec 1 00:29 version.sh
-rwxr-xr-x 1 root root 5495 Dec 1 00:29 tool-wrapper.sh
-rwxr-xr-x 1 root root 1904 Dec 1 00:29 startup.sh
-rwxr-xr-x 1 root root 1902 Dec 1 00:29 shutdown.sh
-rwxr-xr-x 1 root root 3680 Dec 1 00:29 setclasspath.sh
-rwxr-xr-x 1 root root 1965 Dec 1 00:29 digest.sh
-rwxr-xr-x 1 root root 8509 Dec 1 00:29 daemon.sh
-rwxr-xr-x 1 root root 1922 Dec 1 00:29 configtest.sh
-rwxr-xr-x 1 root root 23170 Dec 1 00:29 catalina.sh
-rw-r--r-- 1 root root 1647 Dec 1 00:30 catalina-tasks.xml
drwxr-xr-x 4 root root 4096 Mar 6 15:11 commons-daemon-1.1.0-native-src
-rwxr-xr-x 1 root root 174304 Mar 6 15:12 jsvc
8.daemon.sh 設置:JAVA_HOME=/application/jdk
test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat
# Set JAVA_HOME to working JDK or JRE
JAVA_HOME=/application/jdk
# JAVA_HOME=/opt/jdk-1.6.0.22
# If not set we'll try to guess the JAVA_HOME
# from java binary if on the PATH
[root@joyway bin]# vi 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.
# -----------------------------------------------------------------------------
#
# 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
ARG0="`dirname $ARG0`/$link"
fi
done
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
while [ ".$1" != . ]
do
case "$1" in
continue
#!/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.
# -----------------------------------------------------------------------------
#
# 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
ARG0="`dirname $ARG0`/$link"
fi
done
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
while [ ".$1" != . ]
do
case "$1" in
# Commons Daemon wrapper script.
# -----------------------------------------------------------------------------
#
# 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
ARG0="`dirname $ARG0`/$link"
fi
done
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
while [ ".$1" != . ]
do
case "$1" in
--java-home )
JAVA_HOME="$2"
shift; shift;
continue
;;
--catalina-home )
CATALINA_HOME="$2"
shift; shift;
continue
;;
--catalina-base )
CATALINA_BASE="$2"
shift; shift;
continue
;;
--catalina-pid )
CATALINA_PID="$2"
shift; shift;
continue
;;
--tomcat-user )
TOMCAT_USER="$2"
shift; shift;
continue
;;
--service-start-wait-time )
SERVICE_START_WAIT_TIME="$2"
shift; shift;
continue
;;
* )
break
;;
esac
done
# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
Darwin*)
darwin=true
;;
esac
# Use the maximum available, or set MAX_FD != -1 to use that
test ".$MAX_FD" = . && MAX_FD="maximum"
# Setup parameters for running the jsvc
#
test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat
# Set JAVA_HOME to working JDK or JRE
# JAVA_HOME=/opt/jdk-1.6.0.22
# If not set we'll try to guess the JAVA_HOME
# from java binary if on the PATH
#
if [ -z "$JAVA_HOME" ]; then
JAVA_BIN="`which java 2>/dev/null || type java 2>&1`"
while [ -h "$JAVA_BIN" ]; do
ls=`ls -ld "$JAVA_BIN"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
JAVA_BIN="$link"
else
JAVA_BIN="`dirname $JAVA_BIN`/$link"
fi
done
test -x "$JAVA_BIN" && JAVA_HOME="`dirname $JAVA_BIN`"
test ".$JAVA_HOME" != . && JAVA_HOME=`cd "$JAVA_HOME/.." >/dev/null; pwd`
else
JAVA_BIN="$JAVA_HOME/bin/java"
fi
# Only set CATALINA_HOME if not already set
test ".$CATALINA_HOME" = . && CATALINA_HOME=`cd "$DIRNAME/.." >/dev/null; pwd`
test ".$CATALINA_BASE" = . && CATALINA_BASE="$CATALINA_HOME"
test ".$CATALINA_MAIN" = . && CATALINA_MAIN=org.apache.catalina.startup.Bootstrap
# If not explicitly set, look for jsvc in CATALINA_BASE first then CATALINA_HOME
if [ -z "$JSVC" ]; then
JSVC="$CATALINA_BASE/bin/jsvc"
if [ ! -x "$JSVC" ]; then
JSVC="$CATALINA_HOME/bin/jsvc"
fi
fi
# Set the default service-start wait time if necessary
test ".$SERVICE_START_WAIT_TIME" = . && SERVICE_START_WAIT_TIME=10
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
JAVA_OPTS=
if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
. "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
# Add on extra jar files to CLASSPATH
test ".$CLASSPATH" != . && CLASSPATH="${CLASSPATH}:"
CLASSPATH="$CLASSPATH$CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-daemon.jar"
test ".$CATALINA_OUT" = . && CATALINA_OUT="$CATALINA_BASE/logs/catalina-daemon.out"
test ".$CATALINA_TMP" = . && CATALINA_TMP="$CATALINA_BASE/temp"
# Add tomcat-juli.jar to classpath
# tomcat-juli.jar can be over-ridden per instance
if [ -r "$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
CLASSPATH="$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar"
else
CLASSPATH="$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar"
fi
# Set juli LogManager config file if it is present and an override has not been issued
if [ -z "$LOGGING_CONFIG" ]; then
if [ -r "$CATALINA_BASE/conf/logging.properties" ]; then
LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
else
# Bugzilla 45585
LOGGING_CONFIG="-Dnop"
fi
fi
test ".$LOGGING_MANAGER" = . && LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER"
# Set -pidfile
test ".$CATALINA_PID" = . && CATALINA_PID="$CATALINA_BASE/logs/catalina-daemon.pid"
# Increase the maximum file descriptors if we can
if [ "$cygwin" = "false" ]; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ "$?" -eq 0 ]; then
# Darwin does not allow RLIMIT_INFINITY on file soft limit
if [ "$darwin" = "true" -a "$MAX_FD_LIMIT" = "unlimited" ]; then
MAX_FD_LIMIT=`/usr/sbin/sysctl -n kern.maxfilesperproc`
fi
test ".$MAX_FD" = ".maximum" && MAX_FD="$MAX_FD_LIMIT"
ulimit -n $MAX_FD
if [ "$?" -ne 0 ]; then
echo "$PROGRAM: Could not set maximum file descriptor limit: $MAX_FD"
fi
else
echo "$PROGRAM: Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# Java 9 no longer supports the java.endorsed.dirs
# system property. Only try to use it if
# JAVA_ENDORSED_DIRS was explicitly set
# or CATALINA_HOME/endorsed exists.
ENDORSED_PROP=ignore.endorsed.dirs
if [ -n "$JAVA_ENDORSED_DIRS" ]; then
ENDORSED_PROP=java.endorsed.dirs
fi
if [ -d "$CATALINA_HOME/endorsed" ]; then
ENDORSED_PROP=java.endorsed.dirs
fi
# ----- Execute The Requested Command -----------------------------------------
case "$1" in
run )
shift
"$JSVC" $* \
$JSVC_OPTS \
-java-home "$JAVA_HOME" \
-pidfile "$CATALINA_PID" \
-wait "$SERVICE_START_WAIT_TIME" \
-nodetach \
-outfile "&1" \
-errfile "&2" \
-classpath "$CLASSPATH" \
"$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMP" \
$CATALINA_MAIN
exit $?
;;
start )
"$JSVC" $JSVC_OPTS \
-java-home "$JAVA_HOME" \
-user $TOMCAT_USER \
-pidfile "$CATALINA_PID" \
-wait "$SERVICE_START_WAIT_TIME" \
-outfile "$CATALINA_OUT" \
-errfile "&1" \
-classpath "$CLASSPATH" \
"$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMP" \
$CATALINA_MAIN
exit $?
;;
stop )
"$JSVC" $JSVC_OPTS \
-stop \
-pidfile "$CATALINA_PID" \
-classpath "$CLASSPATH" \
-D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMP" \
$CATALINA_MAIN
exit $?
;;
version )
"$JSVC" \
-java-home "$JAVA_HOME" \
-pidfile "$CATALINA_PID" \
-classpath "$CLASSPATH" \
-errfile "&2" \
-version \
# Commons Daemon wrapper script.
# -----------------------------------------------------------------------------
#
# 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
ARG0="`dirname $ARG0`/$link"
fi
done
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
while [ ".$1" != . ]
do
case "$1" in
continue
;;
continue
;;
continue
;;
continue
;;
shift; shift;
;;
esac
done
# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
case "`uname`" in
;;
;;
esac
# Use the maximum available, or set MAX_FD != -1 to use that
test ".$MAX_FD" = . && MAX_FD="maximum"
# Setup parameters for running the jsvc
#
test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat
# Set JAVA_HOME to working JDK or JRE
# JAVA_HOME=/opt/jdk-1.6.0.22
# If not set we'll try to guess the JAVA_HOME
# from java binary if on the PATH
#
if [ -z "$JAVA_HOME" ]; then
JAVA_BIN="`which java 2>/dev/null || type java 2>&1`"
fi
done
test -x "$JAVA_BIN" && JAVA_HOME="`dirname $JAVA_BIN`"
test ".$JAVA_HOME" != . && JAVA_HOME=`cd "$JAVA_HOME/.." >/dev/null; pwd`
else
JAVA_BIN="$JAVA_HOME/bin/java"
JAVA_HOME=/application/jdk
"daemon.sh" 275L, 8537C written
9.啓動tomcat
[root@joyway bin]# ./startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@joyway bin]#
10.查看Tomcat進程:
[root@joyway bin]# ps -ef|grep tomcat
root 27655 1 24 15:18 pts/3 00:00:02 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat -Dcatalina.home=/application/tomcat -Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 27701 26870 0 15:18 pts/3 00:00:00 grep --color=auto tomcat