From Evernote: |
6. 架設Tomcat 6 MySql VPS CentOs 6 Tomcat60自動啟動 |
6. Tomcat60自動啟動
到先到 /usr/share/下,下戴Tomcat60,連結網址參照http://tomcat.apache.org/download-60.cgi
6-1 到init.d目錄下新建tomcat6的啟動檔
[root@jay ~]# cd /etc/init.d #到init.d目錄下 [root@jay init.d]# vi tomcat6 |
#!/bin/bash # chkconfig: 2345 80 20 # Description: Tomcat Server basic start/shutdown script # /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine TOMCAT_HOME=/usr/share/tomcat60/bin START_TOMCAT=/usr/share/tomcat60/bin/startup.sh STOP_TOMCAT=/usr/share/tomcat60/bin/shutdown.sh start() { echo -n "Starting tomcat6: " cd $TOMCAT_HOME ${START_TOMCAT} echo "done." } stop() { echo -n "Shutting down tomcat6: " cd $TOMCAT_HOME ${STOP_TOMCAT} echo "done." } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0 |
6-2
改變檔案權限
[root@jay init.d]# chmod 755 tomcat6 |
6-3 確認有chkconfig 沒有請安裝 請到6-3-1
[root@jay init.d]# chkconfig --help #試看是否有安裝chkconfig 如出現version為已安裝 chkconfig version 1.3.49.3 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig [--list] [--type <type>] [name] chkconfig --add <name> chkconfig --del <name> chkconfig --override <name> chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities> [root@jay init.d]# |
6-3-1 沒有的話請安裝chkconfig
[root@jay bin]# sudo apt-get install chkconfig #安裝chkconfig |
6-4 加入自動啟動設定檔
[root@jay init.d]# chkconfig --add tomcat6 |
5-4 出現tomcat6 0:off 1:off 2:on 3:on 4:on 5:on 6:off
成功設定重開reboot後tomcat會自動啟動
[root@jay init.d]# find . -name "*tomcat6" ./tomcat6 [root@jay init.d]# chkconfig --list tomcat6 tomcat6 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@jay init.d]# reboot |
沒有留言:
張貼留言