:::PunLib | Welcome:::
Welcome 54.80.158.127
PunLib Home Contacts PunLib on Facebook Follow PunLib on Twitter PunLib at LinkedIn RSS Feed Image Add This Logo
Quick Links

Tomcat Installation

Installing from OS Online Repositories

For a standard installation you can depend on official repositories/libraries that indivisual distributions of linux maintain. All you need is a working internet connection. They provide quite a compatible and stable versions of softwares/packages for the current versions of OS.

For Example, you can install tomcat on debian/ubuntu with a single command as,

# apt-get install tomcat6

For Centos/Red Hat you can proceed as,

# yum install tomcat6

When installing from online repositories the biggest benefit is that the installation and after-install configuration is done automatically. It just runs like out of box. The services and inits are configured automatically, required users are created and configured automatically. But this is not you need always. You need a better control. Or you may not have access to the online repositories as you may not have to required license to use them in case of commercial distros. In that case you can build from source or install from binaries

Installing from Source

Download the tomcat Source file from http://tomcat.apache.org I have downloaded tomcat 6 file here

apache-tomcat-6.0.36.tar.gz

Untar the file as follows,

# tar -zxvf apache-tomcat-6.0.36.tar.gz

You will get a folder like

apache-tomcat-6.0.36

Now create a folder called tomcat at the location where you want to install it and move the contents there. I am installing to /usr/local/ So, I am proceeding as,

# mkdir /usr/local/tomcat
# mv apache-tomcat-6.0.36/* /usr/local/tomcat/

Thats it. You have installed tomcat to /usr/local/tomcat/ folder.

Add the following line at the end of the /etc/profile file as,

export CATALINA_HOME=/usr/local/tomcat

Varifying the Installation

You can varify if the tomcat has been installed correctly and is working by visiting the tomcat default page at,

From the same machine,

http://localhost:8080

From other client,

http://(server_ip):8080

It should show you the tomcat dafault page.

Tomcat Users

Make a user owner of the tomcat directory. You can add a new user and group with the tomcat as his/her home directory as,

# groupadd webadmin
# useradd -g webadmin -d /usr/local/tomcat/ webadmin

You also need to add the user to the 'www-data' group. This group already exists. Execute the following command,

# usermod -G www-data webadmin

Modify tomcat user file at /usr/local/tomcat/conf/tomcat-users.xml. You need to edit the lines that look like,

<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->

Here add the new user mentioning his/her username and password and assigning required roles. Don't forget to uncomment the lines by removing the tags. It should look something like,

 <role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="admin"/>
<user username="webadmin" password="(user_password)" roles="tomcat,admin,role1"/>

Tomcat Auto-start

Create a file with the following text in the /etc/init.d/ folder,

#Tomcat auto-start, start, stop and restart script
# chkconfig: 345 99 01

#this path should point to your JAVA_HOME Directory
export JAVA_HOME=/usr/java/jdk1.6.0_39/
case $1 in

#Change the path to the scripts in the following lines according to your server

start)
  sh /usr/local/tomcat/bin/startup.sh
  ;;

stop)
  sh /usr/local/tomcat/bin/shutdown.sh
  ;;

restart)
  sh /usr/local/tomcat/bin/shutdown.sh
  sh /usr/local/tomcat/bin/startup.sh
  ;;
esac

exit 0

Change the JAVA_HOME and tomcat paths according to your server configuration,

Make the file executable as chmod 755 tomcat

RHEL/Centos

Now, to make your tomcat start at system startup run the following command,

# chkconfig --add tomcat

Then,

# chkconfig tomcat on

Now if everything goes fine your tomcat will start like any other daemon service on system startup. Also you can start and stop tomcat using commands like,

# /etc/init.d/tomcat start/stop/restart
# service tomcat start/stop/restart

Debian/Ubuntu

To make your tomcat start at system startup,

# Update-rc.d tomcat defaults

Now you can start, stop and restart your tomcat service as,

# /etc/init.d/tomcat start/stop/restart
# service tomcat start/stop/restart


Title - Installing Tomcat | Author - Amandeep Kapila | Article ID - 00000000039 | Last Updated - 2014-12-05 00:53:19 | Keywords - Tomcat, Web Server, Java Web Server, Tomcat Web Publishing

Comments:

Comments

Your Name:
Your Email:
Comments:
       


© 2008-15 Punlib
All Rights Reserved ((Read Best View))