概述
配置用service 启动tomcat
在用RedHat最为服务器的操作系统的时,一般情况下用service启动及其关闭服务,为了让我们自己用着习惯,所以就配置了用service 启动和关闭tomcat服务,当然在这里我是用配置tomcat环境,进行配置该项服务的,如果您要是配置该项服务,请您自己动手配置一下tomcat服务,在这里就略过
1创建tomcat用户
#useradd -s /sbin/nologin tomcat
2 进入/usr/local/tomcat/bin目录下面
#cd /usr/local/tomcat/bin
3 解压jsvc.tar.gz 文件并进入该目录
#tar xvf jsvc.tar.gz
#cd jsvc-src
#bash configure
#make
在该目录下面生成jsvc,并把该文件复制到上一级目录中去
#cp jsvc ../
4并把/usr/local/tomcat 的用户及其组全部修改为tomcat
#chown -R tomcat.tomcat /usr/local/tomcat
#cd native
5 查找脚本文件Tomcat5.sh 并把该文件复制到/etc/init.d/ ,并改名为tomcat
#cp Tomcat5.sh /etc/init.d/tomcat
修改权限
#chmod 755 –R /etc/init.d/tomcat
6修改/etc/init.d/tomcat
注:红色的部分为修改部分
#!/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:
#
# <!-- 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"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#description:this is tomcat start script
#chkconfig: 345 88 14
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=/usr/local/tomcat/bin
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/tomcat/
CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
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/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/jsvc
-stop
-pidfile $PID_FILE
org.apache.catalina.startup.Bootstrap
exit $?
;;
*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac
7 把tomcat添加到自动启动列队中
#chkconfig --add tomcat
#chkconfig tomcat on
8 验证service 启动和关闭tomcat服务,验证的时查看对应的端口号
#service tomcat start
#netstat -tunlp
#service tomcat stop
#netstat -tunlp
#service tomcat start
9在浏览器中输入
http://localhost
转载于:https://my.oschina.net/u/3054960/blog/842061
最后
以上就是幽默酸奶为你收集整理的配置service启动以及关闭tomcat服务的全部内容,希望文章能够帮你解决配置service启动以及关闭tomcat服务所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复