Make sure there is a valid user "tomcat" and that this user has rw permissions in
the $CATALINA_HOME/conf and $CATALINA_HOME/logs directories. Also make sure that
$JAVA_HOME is set. You will start Tomcat as user "tomcat" to avoid running it as root.
The Apache server is started as root because it uses port 80 (lower than 1024) but
it spawns processes that run as "nobody".
Save the following scripts as /etc/init.d/tomcat
and
/etc/init/apache
. They will automatically be read and run at boot time.
Check the log files if it does not start properly.
Make a link to it from /etc/rc5.d
such as:
cd /etc/rc5.d sudo ln -s ../init.d/tomcat S71tomcat sudo ln -s ../init.d/apache S72apache ---------------------------- /etc/init.d/tomcat ------------------------ #!/bin/bash # # tomcat # # chkconfig: # description: Start up the Tomcat servlet engine. # Source function library. . /etc/init.d/functions RETVAL=$? CATALINA_HOME="/usr/apps/apache/tomcat/jakarta-tomcat-4.0.4" case "$1" in start) if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Starting Tomcat" /bin/su tomcat $CATALINA_HOME/bin/startup.sh fi ;; stop) if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh fi ;; *) echo $"Usage: $0 {start|stop}" exit 1 ;; esac exit $RETVAL ----------------------- end of /etc/init.d/tomcat ---------------------- ---------------------------- /etc/init.d/apache ------------------------ #!/bin/bash # # apache # # chkconfig: # description: Start up the Apache web server. # Source function library. . /etc/init.d/functions RETVAL=$? APACHE_HOME="/usr/apps/apache/apache" case "$1" in start) if [ -f $APACHE_HOME/bin/apachectl ]; then echo $"Starting Apache" $APACHE_HOME/bin/apachectl start fi ;; stop) if [ -f $APACHE_HOME/bin/apachectl ]; then echo $"Stopping Apache" $APACHE_HOME/bin/apachectl stop fi ;; *) echo $"Usage: $0 {start|stop}" exit 1 ;; esac exit $RETVAL ----------------------- end of /etc/init.d/apache ----------------------
These instructions where tested by Matt Raible on Red Hat Linux 7.3 with Apache 2.0.42 and Tomcat 4.0.5.