1. Tomcat Boot up
Method One, modify the system files (already tried, can)
1. Modify/etc/rc.d/rc.local
Vi/etc/rc.d/rc.local
2. Add the following two lines of script, remember the two lines, only the second line is not, you must add the first row. At the end of the/etc/rc.d/rc.local file, add:
Export java_home=/usr/java/jdk1.7.0_60
/usr/local/tomcat/bin/startup.sh start
Description:/usr/java/jdk1.7.0_60 is the JDK installation directory
/usr/local/tomcat is a tomcat-installed directory
3. Note: Modify the rc.local file to be executable
chmod +x rc.local
Method Two,
Shell script Startup
Setting up the boot-up service in Linux requires a/ETC/RCX.D under the load. In addition, you need to/etc/init.d some startup scripts. In fact, it is very simple to export the required environment variables, such as Java_home,jre_home, Catalina_home, Catalina_base and so on, and then directly call $catalina_home/bin/ Startup.sh will be able to start successfully.
The first step: we create a new file under/ETC/INIT.D Tomcat (need to operate under root privileges)
[Java]View PlainCopyprint?
- Vi/etc/init.d/tomcat
Write down the following code, Tomcat self-launching script:
[Java]View PlainCopyprint?
- #!/bin/sh
- # chkconfig: 345
- # Description:auto-starts Tomcat
- #/ETC/INIT.D/TOMCATD
- # Tomcat Auto-start
- # Source function library.
- #. /etc/init.d/functions
- # source Networking configuration.
- #. /etc/sysconfig/network
- retval=0
- Export JAVA_HOME=/USR/JAVA/JDK1. 7.0_60
- Export JRE_HOME=/USR/JAVA/JDK1. 7.0_60/jre
- Export Catalina_home=/usr/local/tomcat
- Export Catalina_base=/usr/local/tomcat
- Start ()
- {
- if [-f $CATALINA _home/bin/startup.sh];
- Then
- echo $"Starting Tomcat"
- $CATALINA _home/bin/startup.sh
- Retval=$?
- echo "OK"
- return $RETVAL
- Fi
- }
- Stop ()
- {
- if [-f $CATALINA _home/bin/shutdown.sh];
- Then
- echo $"Stopping Tomcat"
- $CATALINA _home/bin/shutdown.sh
- Retval=$?
- Sleep 1
- PS-FWWU Root | grep tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs Kill-9
- echo "OK"
- # [$RETVAL-eq 0] && rm-f/var/lock/ ...
- return $RETVAL
- Fi
- }
- Case "$" in
- Start
- Start
- ;;
- Stop
- Stop
- ;;
- Restart
- echo $"restaring Tomcat"
- $0 Stop
- Sleep 1
- $0 Start
- ;;
- *)
- echo $"Usage: $ {start|stop|restart}"
- Exit 1
- ;;
- Esac
- Exit $RETVAL
Here is a special reminder to note that this sentence Ps-fwwu root | grep tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9, the person familiar with the Linux command should be aware of the meaning of this sentence, here simply say the first half, query the root user tomcat process PID, personal changes according to the actual situation.
Step two: After you save the exit, add executable permissions to it
[Java]View PlainCopyprint?
- chmod +x/etc/init.d/tomcat
Step Three: Mount
Connect the shell file link to the/etc/rc2.d/directory. The numbers in the/etc/rcx.d/directory for Linux represent the different run level, which is the order in which the boot starts, Ubuntu9.10 There are 0-5 six level, can not be casually connected to other directories, it may be in that directory when the program started Tomcat needed to some of the library has not been loaded, with the ln command link tomcat links Past: sudo ln-s/etc/init.d/ Tomcat/etc/rc2.d/s16tomcat. The naming rules under the RCX.D directory are very specific, more different needs may be the beginning of s, may also be the beginning of K, after the numbers represent their starting order, detailed look at the Readme file in their respective directories.
[Java]View PlainCopyprint?
- Ln-s/etc/init.d/tomcat/etc/rc2.d/s16tomcat
Fourth step: Set the script to boot from
Set this script to automatically execute when the system starts, and stop automatically when the system shuts down, using the following command:
[Java]View PlainCopyprint?
- Chkconfig--add Tomcat
Fifth Step: Verify
Execute sudo reboot. After rebooting, you will find that Tomcat has run successfully.
Digression: After adding this script we start, stop, restart Tomcat to use the command directly
[Java]View PlainCopyprint?
- Service Tomcat Start
- Service Tomcat Stop
- Service Tomcat Restart
Other tomcat settings commands are: Chkconfig--list Tomcat chkconfig Tomcat on, and you can try to find out what the effect is.
Mysql
Command echo "service mysqld start" >>/etc/rc.local
Or go to/etc/directory, direct vim rc.local edit rc.local file, add "service mysqld start" in the last line, save exit
You can use chkconf--list
View the configuration of the boot start
Configure Tomcat, MySQL boot on Linux