How to Setup Additional Tomcat Instances on your Linux Server
Tomcat is a stand-alone application web server which serves web pages containing Java Server Page(JSP) coding. It provides an environment to execute dynamic applications, like JSP and Java servlets.
It communicates with Apache via mod_jk and support servlets and JSPs. Tomcat can be used as an independent web server, with its own internal HTTP server, or can be used in combination with other web servers, like Apache webserver.
JDK(Java Development Kit)
For proper execution, Tomcat requires JDK(Java Development Kit). JDK that contains API classes, Java compiler(javac), Java Virtual Machine(JVM) provides the basic tools to compile Java applications and applets.
You can download the latest version of JDK(JDK 7) from Sun’s Java web URL’s at:
Unpack and install JDK in the directory /usr/local/. Now, we need to define the environment variable JAVA_HOME, such that it points to the java installation directory “/usr/local/jdk1.5.0“.
Add the following lines to the “/etc/bashrc” or “/etc/profile” file, so that the environment variable can be used by all aplications/users in the server.
JAVA_HOME=/usr/local/jdk1.5.0 export JAVA_HOME
[ You don’t have to be an expert to keep your servers fast and stable. Click here to keep your servers lightning fast with our 24/7 Server Administration services. ]
The Tomcat complete package is available for download at the following URL :
Download the latest version of Tomcat and Install it in the /usr/local directory.
mv apache-tomcat-5.5.26.tar.gz /usr/local tar -xvzf apache-tomcat-5.5.25.tar.gz
Now, create the following symbolic link.
ln -s /usr/local/apache-tomcat-5.5.25 /usr/local/tomcat
We can then run the Tomcat web server using a seperate user “tomcat”. Add the user and group “tomcat”.
groupadd tomcat useradd -g tomcat -c "Tomcat User" -d /usr/local/tomcat tomcat passwd tomcat <password for user>
Change the ownership of Tomcat installation directories.
chown tomcat:tomcat /usr/local/tomcat chown -R tomcat:tomcat /usr/local/apache-tomcat-5.5.25
The installation of Tomcat is now complete. We can start the Tomcat instance using a startup script “/usr/local/tomcat/bin/startup.sh“. Also, make sure to define the variable CATALINA_HOME in the script “/usr/local/tomcat/bin/catalina.sh“.
The default Tomcat configuration will service HTTP requests on port 8080. You can access this Tomcat instance using the URL http://server_IP:8080/, where server_IP is the address of the machine where we just now installed the Tomcat server.
In order to shut down the Tomcat service, use the script :
You can access the Tomcat Manager Interface corresponding to this Tomcat installation using the URL:
You can also configure the Manager Application Access using a username and password combination that has the role “manager” associated to them. All you have to do to enable this access is edit the Tomcat users configuration file.
By default, the Manager application is completely disabled. To enable access to the Manager web application, add the following entry in /usr/local/tomcat/conf/tomcat-users.xml.
<tomcat-users> <role rolename="manager"/> <user username="admin" password="tomcat" roles="manager"/> </tomcat-users>
Once you restart the Tomcat service after this, you will be able to access the Manager interface using the login details admin/tomcat.