How to configure Tomcat 6 as a service in linux

Source: Internet
Author: User


I downloaded 6.0.1 _ 31 from www.atat.org on the official website, decompressed the package, and stored it in:/usr/share/tomcat6. I used a root user to log on, the following describes the specific operation steps. 1. in/usr/share/tomcat6/bin, the commons-daemon-native.tar.gz compressed package is 2 bytes to decompress commons-daemon-native.tar.gz [root @ localhost ~]. # Tar-zxvf commons-daemon-native.tar.gz 3, decompression is complete, the commons-daemon-1.0.2-native-src folder (directory) 1, enter the unix directory under the commons-daemon-1.0.2-native-src [root @ localhost ~] # Ls [root @ localhost ~] # Cdcommons-daemon-1.0.2-native-src/unix 2, configure configuration file found, execute the following command to modify properties [root @ localhost ~] # Chmod 777 configure 4. Execute the configure file [root @ localhost ~] #./Configure 5. Compile [root @ localhost ~] # Make # [root @ localhost ~] # Make clean [root @ localhost ~] # Make # recompile successful 6. After the compilation is complete, the jsvc folder appears. Copy jsvc to the/usr/share/tomcat6/bin directory [root @ localhost ~]. # Cp jsvc/usr/share/tomcat6/bin restart 10. Compile the tomcat6 startup service configuration file in the/etc/init. d/directory. [Root @ localhost ~] # Cd/etc/init. d/[root @ localhost ~] # Vi tomcat6 enter the following content #! /Bin/sh # tomcat: Start/Stop/Restart tomcat # chkconfig: 2345 85 15 # description: apache Tomcat 6 # 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/jdk1.6.0 _ 31 # modify CATALINA_HOME =/usr/share/tomcat6 according to your actual tomcat location location to modify DAEMON_HOME = $ CATALINA_HOME/B In # I did not use the user. # TOMCAT_USER = tomcat # for multi instances adapt those lines. TMP_DIR = $ CATALINA_HOME/tmpPID_FILE =/var/run/jsvc. pidCATALINA_BASE = $ CATALINA_HOME. /etc/rc. d/init. d/functionsCATALINA_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 Tom Cat. # 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 echo "***************************** [OK] "} Stop () {echo-n $" Stopping Tomcat6: "# $ DAEMON_HOME/jsvc \-stop \-pidfile $ PID_FILE \ org. apache. catalina. startup. bootstrap echo "**************************** [OK]"} 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 ec Ho-n "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 ######## 11. The input is complete, press Esc. Input: wq save and quit and grant the executable permission to the/etc/init. d/tomcat6 file [root @ localhost ~] # Chmod 777/etc/init. d/tomcat6 ------------------ add service --------------------------------------------- 12, [root @ localhost ~] # Chkconfig -- add tomcat6 # add tomcat Service 13 and [root @ localhost ~] # Chkconfig-list | grep tomcat6 # Check whether the tomcat service is added -------------------- start the service --------------------------------------- 14. [root @ localhost ~] # Service tomcat6 start # start tomcat service 15 and [root @ localhost ~] # Service tomcat6 stop # stop tomcat service 16 and [root @ localhost ~] # Service tomcat6 restart # restart tomcat 17 and [root @ localhost ~] # Service tomcat6 status # view tomcat service startup status by fly542

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.