| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
8年前发布

tomcat的linux下开机脚本

Let's pretend that ${CATALINA_HOME} is /home/mwood/apache-tomcat-7.0.37. First, in ${CATALINA_HOME}/bin, create a file called setenv.sh and put this in it:

#!/bin/sh    export CATALINA_HOME=/home/mwood/apache-tomcat-7.0.37  export JAVA_HOME=/usr/local/jdk1.7.0_15  export CATALINA_OPTS="-Dreadonly.kvs.pg.username=bd_readonly -Dreadonly.kvs.pg.password=foisgras -Dreadonly.kvs.pg.host=kbdash -Dreadonly.kvs.pg.port=5432 -Dreadonly.kvs.pg.db=kb_2m_kvs"  export CATALINA_PID=${CATALINA_HOME}/var/catalina.pid

Let's pretend you want to run Tomcat as user mwood. Now, as root, create this file in /etc/init.d:

#!/bin/bash    CATALINA_USER=mwood  CATALINA_HOME=/home/mwood/apache-tomcat-7.0.37  CATALINA_BIN="${CATALINA_HOME}/bin"  CATALINA_CMD="${CATALINA_BIN}/catalina.sh"  JAVA_HOME=/usr/local/jdk1.7.0_15  CATALINA_PID=${CATALINA_HOME}/var/catalina.pid    case "$1" in      start)          if [ -f "$CATALINA_PID" ]; then              echo "$CATALINA_PID already exists; process is already running or crashed" 1>&2          else              echo "Starting Tomcat..."              su - $CATALINA_USER -c "${CATALINA_CMD} start"          fi          ;;      status)          if [ ! -f "$CATALINA_PID" ]; then              echo "$CATALINA_PID does not exist; process does not exist or has gone rogue"          else              echo "pid file exists: ${CATALINA_PID}"              PID=$(cat $CATALINA_PID)              echo "should be running with pid ${PID}"              if [ -x "/proc/${PID}" ]; then                  echo "process exists in process list at /proc/${PID}"              else                  echo "process does not exist in process list (could not find it at /proc/${PID}; did it die without nuking its own pid file?"              fi          fi          ;;      stop)          if [ ! -f "$CATALINA_PID" ]; then              echo "$CATALINA_PID does not exist; process does not exist or has gone rogue" 1>&2          else              PID=$(cat $CATALINA_PID)              echo "Stopping..."              su - $CATALINA_USER -c "${CATALINA_CMD} stop"              while [ -x "/proc/${PID}" ]; do                  echo "Waiting for Tomcat to shut down..."                  sleep 1              done              echo "Tomcat stopped"          fi          ;;      *)          echo "Please use start or stop as first argument" 1>&2          ;;  esac

Allow Tomcat to Run as Unpriveledged User But Still Serve Port 80

iptables --table nat --append PREROUTING --protocol tcp --destination-port 80 \      --in-interface eth0 --jump REDIRECT --to-port 8080

NOTE!The above rule will not redirect local requests, since these bypass the PREROUTING chain. Any browsers or other client software running on the server itself will either have to connect directly to port 8080. In most situations, this will be acceptable.

How to Start Tomcat in Remote Debugging Mode

1 Dec 2014

Do this, and you can latch onto your remote tomcat with Eclipse and debug it, at port 8000

$ cd ~/apache-tomcat-7.0.53/bin  $ ./catalina.sh jpda start

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1449465820598.html
Tomcat 应用服务器