Alex刺客

Dancing fingers, damage world. -- 舞动手指,破坏世界.

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  57 随笔 :: 0 文章 :: 76 评论 :: 0 Trackbacks
Configured Linux installation services tomcat6

1. Installation Preparation.


    a) download tomcat.

        ......

    b) copy to '/opt' directory.

1         cp apache-tomcat-6.0.29.tar.gz /opt/

    c) extract files.

1         cd /opt/
2         tar zxvf apache-tomcat-6.0.29.tar.gz


    d) rename.

1         mv apache-tomcat-6.0.29 tomcat6


    e) Test whether you can run.

1         cd tomcat6/bin/
2         ./catalina.sh run

2. Installation commons-daemon-native
(Reference)
http://tomcat.apache.org/tomcat-7.0-doc/setup.html
   
    a) extract files.
        'commons-daemon-native' in the bin directory.
       
1         tar xvfz commons-deamon-native.tar.gz

    b) configuration commons-daemon-native.
   
1         cd commons-daemon-1.0.2-native-src/unix
2         ./configure

    c) compiled.

1         make # Make an error the first time.
2         make clean
3         make # Once again make compile successfully.

    d) copy 'jsvc' to 'bin' directory.
1         cp jsvc ../..

3. Set the startup script.
(Reference) 
native/Tomcat5.sh
http://hi.baidu.com/wallace_gong/blog/item/7b27c449ad74502d09f7ef83.html
http://blog.csdn.net/luinstein/archive/2009/08/28/4493055.aspx

    a) editing shell startup file tomcat5.
1         cd /etc/init.d/
2         vim tomcat6

(Refer to the following document)
#!/bin/sh
#
 tomcat: Start/Stop/Restart tomcat
#
#
 chkconfig: 2345 85 15
#
 description: Apache tomcat6

# 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"/>
#
#
JAVA_HOME=/usr/java/latest
CATALINA_HOME=/opt/tomcat6
DAEMON_HOME
=$CATALINA_HOME/bin
# I did not use the user.
#
TOMCAT_USER=tomcat

# for multi instances adapt those lines.
TMP_DIR=$CATALINA_HOME/tmp
PID_FILE
=/var/run/jsvc.pid
CATALINA_BASE
=$CATALINA_HOME
/etc/rc.d/init.d/functions
CATALINA_OPTS
=
CLASSPATH
=\
$JAVA_HOME
/lib/tools.jar:\
$CATALINA_HOME
/bin/commons-daemon.jar:\
$CATALINA_HOME
/bin/bootstrap.jar

start() {
    echo 
-n $"Starting Tomcat6: "
    
# If you want to specify a user to run Tomcat.
    #increase the 'user $ TOMCAT_USER \' to the parameter list.
    $DAEMON_HOME/jsvc \
    
-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
}

stop() {
    echo 
-n $"Stopping Tomcat6: "
    
#
    $DAEMON_HOME/jsvc \
    
-stop \
    
-pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
}

status() {
     ps ax 
--width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | awk '{printf $1 " "}' | wc | awk '{print $2}' >/tmp/tomcat_process_count.txt
     read line 
< /tmp/tomcat_process_count.txt
     
if [ $line -gt 0 ]; then
       echo 
-"tomcat6 ( pid "
       ps ax 
--width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap" | awk '{printf $1 " "}'
       echo 
") is running"
     
else
       echo 
"Tomcat6 is stopped"
     fi
}

case 
"$1" in
  start)
    
# Start Tomcat
    start
    exit $?
    ;;

  stop)
    
# Stop Tomcat
    stop
    exit $?
    ;;
  restart)
    
# Restart Tomcat
    stop
    sleep 
3
    start
    exit $?
    ;;
   status)
    status
    exit $?
    ;;
  
*)
    echo 
"Usage: tomcat6 {start|stop|restart|status}"
    exit 
1;;
esac


4. Added to the system service
1     chkconfig --add tomcat6
2     chkconfig --list | grep tomcat6
3     tomcat6            0:off    1:off    2:on    3:on    4:on    5:on    6:off


5. Start and Stop for tomcat service.

[root@localhost init.d]
# service tomcat6 start
Starting Tomcat 
[root@localhost init.d]
# service tomcat6 status
tomcat ( pid 8024 8025 ) is running
[root@localhost init.d]
# service tomcat6 stop
Stopping Tomcat 
[root@localhost init.d]
# service tomcat6 status
Tomcat is stopped
[root@localhost init.d]
# 

最近对英文产生了莫明其妙的好感 -- 嘿嘿.
                                                                                                                                                                                                               author: alex刺客
温馨提示: 转载请保留此文档地址.
Tips: Reprinted Please keep this document URL.
posted on 2010-10-27 19:08 Alex刺客 阅读(1716) 评论(0)  编辑  收藏 所属分类: Linux

只有注册用户登录后才能发表评论。


网站导航: