Objective
In the blog--"VirtualBox install CentOS, and build Tomcat, talking about the build tomcat under the CentOS environment, found that starting Tomcat is not so convenient, if you forget the path, then more trouble!" Of course, forget the path is still there are many ways to get back, then there is no way to set up Tomcat system services, like service iptables start with service Tomcat start to launch Tomcat, the answer must be yes, And listen to my slow way.
Set up Tomcat for Linux system services
1. File Preparation
Copy the catalina.sh to/etc/init.d/(this file is what you go to brain) and rename it to Tomcat.
2. Edit the file
After the file copy is completed, the Tomcat file is edited, Vim Tomcat opens the Tomcat file and presses I for the insert edit, for example, save exit after editing is complete.
3. Add Tomcat as a system service
Before you add Tomcat for system service, view system Services Chkconfig--list, and discover that there are no Tomcat services, such as
Add a file executable permission, and then add Tomcat as a system service, such as
Execute the command chkconfig--list, as
4. Start and close services
Start the service and access it using a browser, such as
Shut down the service, as with other system services, such as
5. Set up the Tomcat service to boot from the system boot (set as System self-boot service)
Directly in the/etc/rc.local file at the end of the Add statement/usr/local/tomcat7/bin/startup.sh, restart the system, run Ps-ef|grep Java, the following information appears, the Tomcat service started!
Of course Tomcat set since boot, restart the system, the most straightforward way to verify that tomcat boot is actually directly access Tomcat cat can be, the following cute cat, then tomcat with the system since the boot!
Close the Tomcat service and run Ps-ef|grep Java, as
Summarize
Configuration is not difficult, as long as attention to some of the details of the problem, I hope we also successfully configured success!
Individuals are not accustomed to tomcat self-priming, more accustomed to service to start and close Tomcat services, personal habits, all based on their preferences, everyone according to their own habits to configure on the line!
If you do not want Tomcat to be self-booting, just use the service command to manage Tomcat, then use the command chkconfig--del Tomcat to remove the Tomcat service from the system service.
To add Tomcat as a Linux system service