How to install Tomcat 7 on a cPanel server?

cPanel’s easyapache script by default install Tomcat version 5.5 and provides no option to upgrade to version 7.x if required, so people who requires Tomcat 7 will have to install/upgrade tomcat manually but the newer version won’t be recognized by cPanel by default and people will have to configure domains manually in the tomcat configuration files.

There is a workaround though, so once Tomcat 7 is installed and some small changes are made, it can be managed from WHM also.

1) Start by installing the available Tomcat version provided by cPanel using the easyapache script. It will install Java on your server so you don’t have to install it manually. cPanel will install Tomcat under /usr/local/jakarta/ directory and a link to tomcat inside it.

# ls -la /usr/local/jakarta
drwxr-xr-x  13 tomcat nobody 4096 Apr 29  2009 apache-tomcat-5.5.25/
lrwxrwxrwx   1 root   root     39 Apr 29  2009 tomcat -> /usr/local
/jakarta/apache-tomcat-5.5.25/

2) Download Tomcat 7 in the /usr/local/jakarta directory and extract it

# cd /usr/local/jakarta
# wget http://apache.cs.utah.edu/tomcat/tomcat-7/v7.0.39/\
bin/apache-tomcat-7.0.39.tar.gz
# tar -zxf apache-tomcat-7.0.39.tar.gz

3) Once the tomcat file is extracted, a new directory ‘apache-tomcat-7.0.39’ will be created under the jakarta folder. Now, remove the old ‘tomcat’ link and create a new symlink to point to the new tomcat directory i.e.

# rm -f tomcat
# ln -s /usr/local/jakarta/apache-tomcat-7.0.39 tomcat

so it looks like follows:

# ls -la /usr/local/jakarta
 drwxr-xr-x  13 tomcat nobody apache-tomcat-5.5.25/
 drwxr-xr-x   9 root   root apache-tomcat-7.0.39/
 -rw-r--r--   1 root   root apache-tomcat-7.0.39.tar.gz
 lrwxrwxrwx   1 root   root tomcat -> /usr/local/jakarta
/apache-tomcat-7.0.39/

4) Now goto the new tomcat directory and compile the newer version

# cd /usr/local/jakarta/tomcat/bin
# tar -zxf commons-deamon-native.tar.gz
# cd commons-daemon-1.0.14-native-src/unix
# ./configure
# make
# cp jsvc ../..   (copies the new file to the bin directory)

5) Now copy the server.xml and workers.properties from the old tomcat installation to the new one. This is required if you already have tomcat enabled on some websites before the upgrade.

# cp -p /usr/local/jakarta/apache-tomcat-5.5.25/conf/server.xml \
/usr/local/jakarta/tomcat/conf/
# cp -p /usr/local/jakarta/apache-tomcat-5.5.25/conf/workers.properties\
/usr/local/jakarta/tomcat/conf/

6) Now, restart the tomcat server

# /usr/local/jakarta/tomcat/bin/shutdown.sh
# /usr/local/jakarta/tomcat/bin/startup.sh
# /etc/init.d/httpd restart

7) Check the tomcat version in use:

# sh /usr/local/jakarta/tomcat/bin/version.sh

If for any reason, you would like to go back to the older Tomcat version, just goto the jakarta folder and change the ‘tomcat’ symlink to the older tomcat folder and restart the tomcat server.

This entry was posted on Tuesday, May 7th, 2013 and is filed under cPanel Management. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.