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.
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
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
30 Comments
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 !!!
Link that /currently/ works: http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz
Or go to http://www.us.apache.org/dist/tomcat/ and find it yourself.
Hello have really challenge, tried installing tomcat7 in centos7 and have failed.
Hi Ejustine, What issue are you facing?
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
Hi, Rahul,
I never thought that tomcat will be easy like this.
Thanks a lot of
Great post. It just made my configuration quick & easy.
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.
Configure LDAP with tomcat in http://www.theseforums.com/FALF
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
Hi,
If I follow this guide and needed to uninstall tomcat, do i just delete the extracted tomcat folder?
Yes, Just delete that folder.
Thanks for share!!
Today I had to do this, and your article was very useful.
Regards.
Cheers mate! Much appreciated 🙂
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?
Hi
I’ve followed the tutorial but once I try to run the new version of Tomcat, it shows following error.
Cannot find apache-tomcat-8.0.18/bin/setclasspath.sh
This file is needed to run this program
Regarding the issue, I also posted a question on stackoverflow. You may find it here
http://stackoverflow.com/questions/28378139/how-to-run-a-new-version-of-tomcat-on-linux
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.
GREAT! Article Rahul, Keep it up, You just save me time…
How do you configure to start on reboot?
Hi Mike,
You may use this script for start/stop tomcat with little changes.
https://coderwall.com/p/yqrusq
Awesome.
great article, it really helped me, as a noob, to understand how to set-up tomcat user accounts, although I used http://www.rosehosting.com/blog/how-to-install-tomcat-8-on-a-centos-6-vps/ to install and set-up java and tomcat 8 on my centos vps as tomcat 8 is required
thanks and keep up the great work,
– cody
how I can to deploy a WAR archive Java web application into server with CentOS?
just move your war file to /usr/share/tomcat/webapps before triggering catalina.sh start command
short but fully problem describing article
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.
Excellent article, Rahul. This helped very much in getting our Tomcat/Eclipse development environment up and running on our Linux servers.
Good article. There are even more tips here on Tomcat installation and setup.
http://wiki.glitchdata.com/index.php?title=Tomcat_Installation
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?
Hi Dan Brian
You can follow this link for running multiple instance on apache tomcat.
http://thelinuxstarter.wordpress.com/2013/12/01/run-multiple-instance-of-apache-tomcat-in-single-server