Apache Tomcat is a open source web server for Java application of Apache Foundation like Apache HTTP server. It used for deploying Java Servlet and JSP applications. To deploy an 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/.

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

Advertisement
Step 1 – Check Java Version

JAVA is the first requirement for Tomcat 7 installation. Make sure you have JAVA SE 7 or 8 version installed in your system. Currently, Java 9 does not support Tomcat. Use the following command to check if you have java installed already on your system.

java -version

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

If you do not have java installed, Use another article to install Java 8 in Red Hat based systems.

Step 2 – Download Tomcat 7 Archive

Download Apache Tomcat archive file from Apache tomcat official download page. You can use below wget command to download it.

cd /tmp
wget http://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.99/bin/apache-tomcat-7.0.99.tar.gz

After competed download extract archive file in /tmp directory and move to the proper location as per your need. We are placing this under /usr/local directory.

tar xzf apache-tomcat-7.0.99.tar.gz
mv apache-tomcat-7.0.99 /usr/local/tomcat7
Step 3 – Start Tomcat Server

Tomcat is very easy to use, There is no need to compile its source. You simply extract the archive and start the tomcat server. Tomcat by default start on port 8080, Make sure no other services are running on the same port using ‘telnet localhost 8080’.

cd /usr/local/tomcat7
./bin/startup.sh

Sample Output

Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /opt/jdk1.8.0_121
Using CLASSPATH:       /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
Step 4 – Access Tomcat in Browser

Tomcat server works on port 8080 default. To access Tomcat on the web browser by connecting your server on port 8080.

 http://localhost:8080 

Install Tomcat 7 CentOS

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" />

Step 6 – Stop Tomcat Server

Finally, if you feel that there is no need for Tomcat in your system, you can simply stop it using the below command from the tomcat home directory.

./bin/shutdown.sh

I hope above steps will help you to set up Tomcat 7 on your server. Read our next article to Install Tomcat 7 on Ubuntu. Tomcat 8 stable release is also available to download. Read our next article to Install Tomcat 8 in Linux

Thanks

Share.

30 Comments

  1. Hello Rahul,
    Is Tomcat 6.x is supported in RHEL 7.x ?
    I have a project running on tomcat 6 on RHEL 5 which needs to be migrated on RHEL 7.
    while running tomcat 6 on RHEL 7 I get below issue.

    Jun 16, 2021 1:32:25 PM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter Request Dumper Filter
    java.lang.ClassNotFoundException: org.apache.catalina.filters.RequestDumperFilter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:201)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:200)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:270)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:272)
    at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:119)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4076)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4730)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:622)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

    let me know your view on this.
    Thanks in advanced !!!

      • Hello RAHUL K how are you ?
        Please ,can you help.
        I have some problems to release the SSO authentification server with LDAP and Kerberos server.this is the documentation but i have a problem :
        -i can’t generate the cas.war file whene i tap :# mvn package install
        ,so this comande give me a lot of ligne of Erreur .
        (i have copy and passte all the commande in the documentation )plz help

  2. Look like this link “http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz” needs to be updated. I was able to use the latest version though, thanks for the instruction.

  3. Hey! I did the following steps but I can’t seem to edit the conf/tomcat-users.xml folder due to restriction issues. Any help? Thanks

  4. Great article, Rahul,

    I am trying to stand up my application in Tomcat-7.0.54 and have followed all your instructions.
    However, when I enter ./startup.sh I get an error message:

    /bin/setclasspath.shache-tomcat-7.0.54
    This file is needed to run this program

    The “shache” looks like I have a typo somewhere. But I’ve looked and don’t see one.
    Can you help?

  5. Thanks for the quick tutorial Rahul. It took all of 5 minutes to get Tomcat 7.0.56 up and running on my Centos 5.x system.

  6. Rahul, you have no clue how much this helped so far. I was struck a whole day figuring out why the way I had installed was not working. Atlast it did work for me perfectly. Thanks alot dude.

  7. Excellent article, Rahul. This helped very much in getting our Tomcat/Eclipse development environment up and running on our Linux servers.

  8. Hi,

    Thank you so much for this article. This helped me a lot since I’m new to linux. Do you have an article about running multiple instances of tomcat7 on CentOS 6?

Leave A Reply


Exit mobile version