Running Tomcat as a service on Linux

If you want to automatically start Tomcat when your system boots and manage it using the service command, you must create an initialization script.

  • Create the following Tomcat initialization script as /etc/rc.d/init.d/tomcat (the script is in the attached file).
  • Change the attributes of the file with chmod 755 tomcat so it can be executed.
  • Add the startup script to your system as follows:
    *chkconfig --add tomcat
  • You will be able to start/stop/restart it using the following commands:
    *service tomcat start
    *service tomcat stop
    *service tomcat restart

If you want Tomcat to start automatically when your system boots, you need to add tomcat to your runlevel as follows:

  • chkconfig --level 3 tomcat on
    *Runlevel 5 is the X Window System, typical for a development computer.
    *Runlevel 3 is typical for a dedicated web server.

Apache and Tomcat can be started in any order, and each can be restarted independently of each other.

Attachment: startup-script.txt

  • No labels