Sunday 15 December 2013

Installing Tomcat 7 on a cPanel Server

When you have installed tomcat by using Easy-Apache then it installed Tomcat 5.5 and if you want to installed Tomcat 7.0.11 then you need to made some necessary changes on the server.

1) First install Tomcat 5.5 by using Easy-Apache means java is also installed at the time of Easy-Apache. The Tomcat 5 is installed in /usr/local/jakarta/ directory with the symbolic link tomcat. For example:
[~]# ll /usr/local/jakarta
drwxr-xr-x  4 tomcat nobody 4096 Apr  5 17:15 ./
drwxr-xr-x 22 root   root   4096 Mar  5 15:39 ../
drwxr-xr-x 12 tomcat nobody 4096 Apr  4 17:02 apache-tomcat-5.5.30/
lrwxrwxrwx  1 tomcat nobody   39 Apr  4 17:04 tomcat -> /usr/local/jakarta/apache-tomcat-5.5.30/

2)  Then download and extract Tomcat 7 in /usr/local/jakarta directory
[~]# cd /usr/local/jakarta
[/usr/local/jakarta]# wget http://apache.cs.utah.edu/tomcat/tomcat-7/v7.0.11/bin/apache-tomcat-7.0.11.tar.gz
[/usr/local/jakarta]# tar -xzvf  apache-tomcat-7.0.11.tar.gz

3) Then Change the tomcat symbolic link to point to your new version (i.e. /usr/local/jakarta/apache-tomcat-7.0.11)
[/usr/local/jakarta]# ln -s /usr/local/jakarta/apache-tomcat-7.0.11 tomcat
Now it shows
[~]# ll /usr/local/jakarta
drwxr-xr-x  4 tomcat nobody 4096 Apr  5 17:15 ./
drwxr-xr-x 22 root   root   4096 Mar  5 15:39 ../
drwxr-xr-x 12 tomcat nobody 4096 Apr  4 17:02 apache-tomcat-5.5.30/
drwxr-xr-x  9 tomcat nobody 4096 Apr  4 17:01 apache-tomcat-7.0.11/
lrwxrwxrwx  1 tomcat nobody   39 Apr  4 17:04 tomcat -> /usr/local/jakarta/apache-tomcat-5.5.30/

4) Then compile the new Tomcat version on cPanel server.
[~]# cd /usr/local/jakarta/apache-tomcat-7.0.11
[/usr/local/jakarta/apache-tomcat-7.0.11]# cd ./bin
[/usr/local/jakarta/apache-tomcat-7.0.11/bin]# tar xvfz commons-deamon-native.tar.gz
[/usr/local/jakarta/apache-tomcat-7.0.11/bin]# cd commons-daemon-1.0.x-native-src/unix
[/usr/local/jakarta/apache-tomcat-7.0.11/bin/commons-daemon-1.0.x-native-src/unix]# ./configure
[~]# make
[~]# cp jsvc ../..
[~]# cd ../../..

5) Copy over any Host blocks from /usr/local/jakarta/tomcat/conf/server.xml from the old Tomcat install to the new Tomcat install (you may or may not be able to set up new hosts through WHM).

6) Copy over /usr/local/jakarta/tomcat/conf/workers.properties from the old Tomcat install to the new Tomcat install.

7) Restart the server
[/]# reboot
Or
[/]# /usr/local/jakarta/tomcat/bin/shutdown.sh
[/]# /usr/local/jakarta/tomcat/bin/startup.sh
[/]# /etc/init.d/httpd restart

9) Check Tomcat Version
 [/]# sh /usr/local/jakarta/tomcat/bin/version.sh
The cPanel EasyApache system makes it easy to recompile Apache with various add-ons and modules.
If you ever need your old Tomcat back just stop Tomcat, flip the tomcat symbolic link back to the old install, and restart Tomcat.

The only thing I've run into with this is that tomcat won't start using the cpanel commands... I can get it to start by calling startup.sh directly, but the /usr/sbin/starttomcat which is what the /scripts/restartsvc_tomcat calls... it spits out a command for the jsvc that we compiled, but nothing happens... it doesn't actually run anything.
ANS: I managed to fix my own issue by hunting through the log files...

In /usr/sbin/starttomcat you have to modify a line since it's still set up for the old tomcat 5.5

Locate: my $jars = "./bootstrap.jar";
Change to: my $jars = "./bootstrap.jar:./tomcat-juli.jar";

Tomcat 7 requires the additional tomcat-juli.jar to start up... once I added that, it starts up perfectly.

No comments:

Post a Comment