Friday, March 7, 2014

How To Install Tomcat 7.0.52 Server on CentOS & RedHat 5/6

Apache Tomcat is an opensource webserver product of Apache Foundation like Apache HTTP server. It is used to deploying Java Servlet and JSP applications. To deploy any application in Tomcat we can simply create a war file and deploy them. For more details about you can visit apache official site http://tomcat.apache.org/ .

tomcat-apache-software-foundation

This article will help you to install Apache Tomcat 7 on CentOS/RHEL servers. We are using CentOS 6.5 and installing Apache tomcat 7. To read more about this release read Tomcat Release Notes.
Step 1: Check JAVA

JAVA is the first requirement of tomcat installation. Use following command to check if you have java installed already on your system.
# java -version

If you do not have java installed, Use this guide to install Java.
Step 2: Download and Extract Tomcat Archive

Download Apache tomcat archive file from Apache tomcat official site using below download url
Download URL: http://tomcat.apache.org/download-70.cgi
# cd /opt
# wget http://www.eu.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz

After competed download extract archive file in /opt directory. You may change this location as per your setup.
# tar xzf apache-tomcat-7.0.52.tar.gz

Step 3: Start Tomcat Service

Tomcat is very easy to use, There are no need to compile its source. You simple extract the archive and start the tomcat server. Tomcat by default start on port 8080, So make sure no other application using the same port.
# cd apache-tomcat-7.0.52
# ./bin/startup.sh

[Sample Output]
Using CATALINA_BASE:   /opt/apache-tomcat-7.0.52
Using CATALINA_HOME: /opt/apache-tomcat-7.0.52
Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.52/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-7.0.52/bin/bootstrap.jar:/opt/apache-tomcat-7.0.52/bin/tomcat-juli.jar

Step 4: Access Tomcat in Browser

Tomcat server works on port 8080 default. Access tomcat on web browser by connecting your server on port 8080.
http://svr2.tecadmin.net:8080

apache-tomcat-setup
Step 5: Setup User Accounts

Finally we need to create user accounts to secure and access admin/manager pages. Edit conf/tomcat-users.xml file in your editor and paste inside <tomcat-users> </tomcat-users> tags.
# user manager can access only manager section.
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />

# user admin can access manager and admin section both.
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />

I hope above steps will help you to setup tomcat on your server.

Thanks

No comments:

Post a Comment