Tomcat
What is Tomcat
Tomcat is the open source implementation of the Java servlet, released under an Apache license. It allows for easy and rapid deployment of Java servlets, typically packaged as "war" files, which contain all of the directories and code necessary to run the application.
Tomcat can run as a standalone webserver, handling all requests for HTTP content, or it can be behind more traditional web servers such as Apache, and only used to serve the dynamic content for which the Java servlet or JavaServer Pages (JSP) are needed.
Installing Tomcat
On a cPanel server typically checking the Tomcat option in EasyApache is enough to install Tomcat:
/scripts/easyapache
However, occasionally it will report that it has successfully installed Tomcat, but Tomcat will fail to run due to Java not being installed.
On core managed servers,
yum install tomcat5
is enough to get tomcat installed.
A tomcat 5 basic init script.
---------------------------- /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 ----------------------
Upgrading to Tomcat6
After Tomcat 5.5 has been installed via EA, procced with the following steps to upgrade to 6.0.32.
cd /usr/local/src/ wget http://layer3.liquidweb.com/tomcat-6.0.32.tar.gz tar -zxvf tomcat-6.0.32.tar.gz cp -R tomcat-6.0.32 /usr/local/jakarta/ chown -R tomcat.nobody /usr/local/jakarta/tomcat-6.0.32 mv /usr/local/jakarta/apache-tomcat-5.5.30 /usr/local/jakarta/apache-tomcat-5.5.30.bak unlink /usr/local/jakarta/tomcat ln -s /usr/local/jakarta/tomcat-6.0.32/ /usr/local/jakarta/tomcat
Now you will need to try to restart apache
/etc/init.d/httpd restart
If apache restarts awesome skip this step if it does not please do the following. If the output of you trying to restart httpd looked something like the following you will need to sync over some config files.
[root@Shooltz.net [/home/shooltz/public_html]$ /etc/init.d/httpd restart Syntax error on line 1 of /usr/local/apache/conf/jk.conf: JkWorkersFile: Can't find the workers file specified httpd not running, trying to start
now cat that file.
[root@Shooltz.net [/usr/local/jakarta/tomcat/conf]$ cat /usr/local/apache/conf/jk.conf JkWorkersFile /usr/local/jakarta/tomcat/conf/workers.properties
In my case it was the workers.properties file that was missing. Do the following for the file your error says:
cp /usr/local/jakarta/apache-tomcat-5.5.30.bak/conf/workers.properties /usr/local/jakarta/tomcat-6.0.32/conf/workers.properties
Now you should be able to restart apache with no problems. Procceed.
Now the only problem at this point is now the scripts to start tomcat appear not to work.
You can start up tomcat6 directly with the following.
/usr/local/jakarta/tomcat-6.0.32/bin/startup.sh
You can stop up tomcat6 directly with the following.
/usr/local/jakarta/tomcat-6.0.32/bin/shutdown.sh
Alternatly in the mean time I have written a init script the you can place in /etc/init.d/ to start and stop this service.
wget -O /etc/init.d/tomcat6 http://layer3.liquidweb.com/scripts/initscripts/tomcat6 chmod +x /etc/init.d/tomcat6
I am working on fixing the problem with the scripts and will update this once I have.
Remove Tomcat from server
Uninstall / Remove Tomcat from Linux server rm -Rf /usr/local/jakarta service chkservd stop cd /etc/chkserv.d rm -Rf tomcat cd /var/run/chkservd rm -Rf Tomcat_JSP service chkservd start rm -f /usr/sbin/starttomcat rm -f /usr/sbin/stoptomcat echo “You must now remove the following lines (if they exist) form httpd.conf and restart apache” echo “## LoadModule jk_module libexec/mod_jk.so ##” echo “## AddModule mod_jk.c ##” echo “## Include=”/usr/local/jakarta/tomcat/conf/mod_jk.conf” ##” echo “## Now exexute restart apache ##” echo “## DONE! ##”