Monday, October 22, 2012

Tomcat 5 Installation on cPanel server and upgarde to Tomcat 7 


Tomcat 5 Installation on cPanel server and upgarde to Tomcat 7 

To install Tomcat, select the Tomcat option in WHM’s EasyApache (Apache Update) or using
“/scripts/easyapache” (without the quotes) in command line. The Tomcat selection is found in
Step 5’s Apache Options area.

It will install Tomcat 5.5.35 on the server.
Steps to upgrade Tomcat to version 7.0.32 are given below.

1) 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.35/
lrwxrwxrwx 1 tomcat nobody 39 Apr 4 17:04 tomcat -> /usr/local/jakarta/apache-tomcat-5.5.35/

2) Then download and extract Tomcat 7 in /usr/local/jakarta directory
[~]# cd /usr/local/jakarta
[/usr/local/jakarta]# wget http://apache.techartifact.com/mirror/tomcat/tomcat-7/v7.0.32/bin/apache-tomcat-7.0.32.tar.gz
[/usr/local/jakarta]# tar -xzvf apache-tomcat-7.0.32.tar.gz
[/usr/local/jakarta]# chown -R tomcat.nobody apache-tomcat-7.0.32/

3) Then Change the tomcat symbolic link to point to your new version (i.e.
/usr/local/jakarta/apache-tomcat-7.0.32)
[/usr/local/jakarta]# rm -rf tomcat
[/usr/local/jakarta]# ln -s /usr/local/jakarta/apache-tomcat-7.0.32 tomcat
[/usr/local/jakarta]# chown -h tomcat.nobody tomcat

4) Then compile the new Tomcat version on cPanel server.
[~]# cd /usr/local/jakarta/apache-tomcat-7.0.32
[/usr/local/jakarta/apache-tomcat-7.0.32]# cd ./bin
[/usr/local/jakarta/apache-tomcat-7.0.32/bin]# tar xvfz commons-daemon-native.tar.gz
[/usr/local/jakarta/apache-tomcat-7.0.32/bin]# cd commons-daemon-1.0.10-native-src/unix
[/usr/local/jakarta/apache-tomcat-7.0.32/bin/commons-daemon-1.0.10-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) To use the web administration gui you have to add the gui role in /usr/local/jakarta/apache-
tomcat-7.0.32/conf/tomcat-users.xml file.
<tomcat-users>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<user username="name" password="pwd" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>

You may copy and paste the above code into the tomcat-users.xml file and change the "name"
and "pwd" fields accordingly.

[/usr/local/jakarta/apache-tomcat-7.0.32/conf]#ls -l
-rw------- 1 tomcat nobody 6818 Oct 11 02:04 server.xml
-rw------- 1 tomcat nobody 1734 Oct 9 13:10 tomcat-users.xml
-rw------- 1 tomcat nobody 5563 Oct 9 12:25 workers.properties

8) 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.

6 comments:

  1. Help!!

    I have followed the steps but when I check the version :
    /usr/local/jakarta/tomcat/bin/version.sh
    is : Apache Tomcat/5.5.36
    when
    /usr/local/jakarta/tomcat/apache-tomcat-7.0.32/bin/version.sh
    is: Apache Tomcat/7.0.32

    ReplyDelete
  2. Hi,

    About this the first output is correct and the second one is you need to upgrade to 7 and check. You get the new version tomcat.

    ReplyDelete
  3. After manipulating step 3, I use the command line: # ll / usr / local / jakarta
    output screen:
    drwxr-xr-x 4 tomcat nobody 4096 Dec 20 08:26. /
    drwxr-xr-x 22 root root 4096 Dec 19 14:19 .. /
    drwxr-xr-x 12 tomcat nobody 4096 Dec 20 08:26 apache-tomcat-5.5.36 /
    drwxr-xr-x 9 tomcat nobody 4096 Dec 20 08:26 apache-tomcat-7.0.32 /
    -rw-r - r - 1 root root 7701019 Oct 3 15:52 apache-tomcat-7.0.32.tar.gz
    lrwxrwxrwx 1 tomcat nobody 39 Apr 4 17:04 tomcat -> / usr/local/jakarta/apache-tomcat-5.5.36 /

    Not know that true?

    ReplyDelete
  4. You can show me the directory structure / usr / local / jakarta / tomcat after upgrade 7 is not?

    Thanks!

    ReplyDelete