Tomcat: Difference between revisions

From Cheatsheet
Jump to navigation Jump to search
Created page with '== 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, ty…'
 
Line 44: Line 44:
  httpd not running, trying to start
  httpd not running, trying to start


Do the following:
now cat that file.


  rsync -avHl /usr/local/jakarta/apache-tomcat-5.5.30.bak/conf/ /usr/local/jakarta/tomcat-6.0.32/conf/
  [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 you should be able to restart apache with no problems.  Procceed.

Revision as of 21:21, 5 March 2011

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.

Upgrading to Tomcat6

Notice: As far as I have tested this will only work on a cpanel box that has had tomcat installed via Easyapache.


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! ##”