David Ghedini

Linux, Java, Oracle, and PostgreSQL

David Ghedini

Monday Feb 28, 2011

Install Tomcat 7 on CentOS, RHEL, or Fedora

This post will cover installing and basic configuration of Tomcat 7 on CentOS 5.x. or CentOS 6.x

Tomcat 7 implements the JavaServer Pages 2.2 and Servlet 3.0 specifications and a number of new features. The Manager application also has a new look and finer-grain roles and access than 6.x

In this post, we'll install Tomcat 7, the new JDK 7, configure Tomcat as a service, create a start/stop script, and (optionally) configure Tomcat to run under a non-root user.

We will also configure basic access to Tomcat Manager and take a quick look at memory management using JAVA_OPTS

Finally, we will look at running Tomcat on port 80 as well as some strategies for running Tomcat behind Apache.

I have just updated this post with Tomcat 7.0.29, the current stable release of Tomcat 7.

If you are using a different release, simply change the file names below accordingly.

To begin, we'll need to install the Java Development Kit (JDK) 7

JDK 1.6 is the minimum JDK version for Tomcat 7.

Step 1: Install JDK 1.7

You can download the latest JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

We'll install the latest JDK, which is JDK 7, Update 5. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I'll need: jdk-7u5-linux-x64.tar.gz.

If you are on 32 bit, you'll need: jdk-7u5-linux-i586.tar.gz

Start by creating a new directory /usr/java:

[root@srv6 ~]# mkdir /usr/java  

Change to the /usr/java directory we created

[root@srv6 ~]# cd /usr/java  
[root@srv6 java ]# 

Download the appropriate JDK and save it to /usr/java directory we created above.

Unpack jdk-7u5-linux-x64.tar.gz in the /usr/java directory using tar -xzf:

[root@srv6 java]# tar -xzf jdk-7u5-linux-x64.tar.gz

This will create the directory /usr/java/jdk1.7.0_05. This will be our JAVA_HOME.

We can now set JAVA_HOME and put Java into the path of our users.

To set it for your current session, you can issue the following from the CLI:
[root@srv6 java]# JAVA_HOME=/usr/java/jdk1.7.0_05
[root@srv6 java]# export JAVA_HOME
[root@srv6 java]# PATH=$JAVA_HOME/bin:$PATH
[root@srv6 java]# export PATH

To set the JAVA_HOME permanently, however, we need to add below to the ~/.bash_profile of the user (in this case, root).
We can also add it /etc/profile and then source it to give to all users.
export JAVA_HOME
export PATH
Once you have added the above to ~/.bash_profile, you should log out, then log back in and check that the JAVA_HOME is set correctly.

[root@srv6 ~]#  echo $JAVA_HOME

Note: If you decided to use JDK 6 rather than 7 as we did above, simply save the JDK 6 bin file to /opt (or another location), then navigate to /usr/java and issue: 'sh /opt/jdk-6u33-linux-x64.bin'. This will create a JAVA Home of /usr/java/jdk1.6.0.33

Step 2: Download and Unpack Tomcat 7.0.29 (or latest)

We will install Tomcat 7 under /usr/share.

Switch to the /usr/share directory:

[root@srv6 ~]# cd /usr/share
[root@srv6 share ]# 
Download apache-tomcat-7.0.29.tar.gz (or the latest version) here

and save it to /usr/share

Once downloaded, you should verify the MD5 Checksum for your Tomcat download using the md5sum command.

[root@srv6 share ]# md5sum apache-tomcat-7.0.29.tar.gz
307076fa3827e19fa9b03f3ef7cf1f3f *apache-tomcat-7.0.29.tar.gz
Compare the output above to the MD5 Checksum provided next to the download link and you used above and check that it matches.

unpack the file using tar -xzf:

[root@srv6 share ]# tar -xzf apache-tomcat-7.0.29.tar.gz  
This will create the directory /usr/share/apache-tomcat-7.0.29

Step 3: Configure Tomcat to Run as a Service.

We will now see how to run Tomcat as a service and create a simple Start/Stop/Restart script, as well as to start Tomcat at boot.

Change to the /etc/init.d directory and create a script called 'tomcat' as shown below.

[root@srv6 share]# cd /etc/init.d
[root@srv6 init.d]# vi tomcat
And here is the script we will use.

# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
export JAVA_HOME
export PATH

case $1 in
sh $CATALINA_HOME/bin/startup.sh
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
exit 0
The above script is simple and contains all of the basic elements you will need to get going.

As you can see, we are simply calling the startup.sh and shutdown.sh scripts located in the Tomcat bin directory (/usr/share/apache-tomcat-7.0.29/bin).

You can adjust your script according to your needs and, in subsequent posts, we'll look at additional examples.

CATALINA_HOME is the Tomcat home directory (/usr/share/apache-tomcat-7.0.29)

Now, set the permissions for your script to make it executable:

[root@srv6 init.d]# chmod 755 tomcat
We now use the chkconfig utility to have Tomcat start at boot time. In my script above, I am using chkconfig: 234 20 80. 2345 are the run levels and 20 and 80 are the stop and start priorities respectively. You can adjust as needed.

[root@srv6 init.d]# chkconfig --add tomcat
[root@srv6 init.d]# chkconfig --level 234 tomcat on
Verify it:

[root@srv6 init.d]# chkconfig --list tomcat
tomcat          0:off   1:off   2:on    3:on    4:on    5:off   6:off
Now, let's test our script.

Start Tomcat:
[root@srv6 ~]# service tomcat start
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.29/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_05
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.29/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.29/bin/tomcat-juli.jar
Stop Tomcat:

[root@srv6 ~]# service tomcat stop
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.29/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_05
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.29/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.29/bin/tomcat-juli.jar
Restarting Tomcat (Must be started first):

[root@srv6 ~]# service tomcat restart
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.29/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_05
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.29/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.29/bin/tomcat-juli.jar
Using CATALINA_BASE:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_HOME:   /usr/share/apache-tomcat-7.0.29
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.29/temp
Using JRE_HOME:        /usr/java/jdk1.7.0_05
Using CLASSPATH:       /usr/share/apache-tomcat-7.0.29/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.29/bin/tomcat-juli.jar
We should review the Catalina.out log located at /usr/share/apache-tomcat-7.0.29/logs/catalina.out and check for any errors.

[root@srv6 init.d]# more /usr/share/apache-tomcat-7.0.29/logs/catalina.out
We can now access the Tomcat Manager page at:

http://yourdomain.com:8080 or http://yourIPaddress:8080 and we should see the Tomcat home page.

Step 4: Configuring Tomcat Manager Access.

Tomcat 7 contains a number of changes that offer finer-grain roles.

For security reasons, no users or passwords are created for the Tomcat manager roles by default. In a production deployment, it is always best to remove the Manager application.

To set roles, user name(s) and password(s), we need to configure the tomcat-users.xml file located at $CATALINA_HOME/conf/tomcat-users.xml.

In the case of our installation, $CATALINA_HOME is located at /usr/share/apache-tomcat-7.0.29.

By default the Tomcat 7 tomcat-users.xml file will have the elements between the and tags commented-out. .

New roles for Tomcat 7 offer finer-grained access and The following roles are now available:


We can set the manager-gui role, for example as below

<role rolename="manager-gui"/>
<user username="tomcat" password="secret" roles="manager-gui"/>

Caution should be exercised in granting multiple roles so as not to under-mind security.

Step 5 (Oprtional): Manage Memory Usage Using JAVA_OPTS.

Getting the right heap memory settings for your installation will depend on a number of factors.

For simplicity, we will set our inital heap size, Xms, and our maximum heap size, Xmx, to the same value of 128 Mb

Simliarly, there are several approaches you can take as to where and how you set your JAVA_OPTS

Again, for simplicity, we will add our JAVA_OPTS memory parameters in our Catalina.sh file.

So, open the Catalina.sh file located under /usr/share/apache-tomcat-7.0.29/bin with a text editor or vi.

Since we are using 128 Mb for both initial and maximum heap size, add the following line to Catalina.sh

JAVA_OPTS="-Xms128m -Xmx128m" 

I usually just add this in the second line of the file so it looks as so:

JAVA_OPTS="-Xms128m -Xmx128m" 
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at

Step 6 (Optional): How to Run Tomcat using Minimally Privileged (non-root) User.

In our Tomcat configuration above, we are running Tomcat as Root.

For security reasons, it is always best to run services with the only those privileges that are necessary.

There are some who make a strong case that this is not required, but it's always best to err on the side of caution.

To run Tomcat as non-root user, we need to do the following:

1. Create the group 'tomcat':

[root@srv6 ~]# groupadd tomcat
2. Create the user 'tomcat' and add this user to the tomcat group we created above.

[root@srv6 ~]# useradd -s /bin/bash -g tomcat tomcat
The above will create a home directory for the user tomcat in the default user home as /home/tomcat

If we want the home directory to be elsewhere, we simply specify so using the -d switch.

[root@srv6 ~]# useradd -g tomcat -d /usr/share/apache-tomcat-7.0.29/tomcat tomcat
The above will create the user tomcat's home directory as /usr/share/apache-tomcat-7.0.29/tomcat

3. Change ownership of the tomcat files to the user tomcat we created above:

[root@srv6 ~]# chown -Rf tomcat.tomcat /usr/share/apache-tomcat-7.0.29/
Note: it is possible to enhance our security still further by making certain files and directories read-only. This will not be covered in this post and care should be used when setting such permissions.

4. Adjust the start/stop service script we created above. In our new script, we need to su to the user tomcat:

# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
export JAVA_HOME
export PATH

case $1 in
/bin/su tomcat $CATALINA_HOME/startup.sh
/bin/su tomcat $CATALINA_HOME/shutdown.sh
/bin/su tomcat $CATALINA_HOME/shutdown.sh
/bin/su tomcat $CATALINA_HOME/startup.sh
exit 0

Step 7 (Optional): How to Run Tomcat on Port 80 as Non-Root User.

Note: the following applies when you are running Tomcat in "stand alone" mode with Tomcat running under the minimally privileged user Tomcat we created in the previous step.

To run services below port 1024 as a user other than root, you can add the following to your IP tables:

[root@srv6 ~]# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080  
[root@srv6 ~]# iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080  

Be sure to save and restart your IP Tables.

Step 8 (Optional): Running Tomcat behind Apache

As an alternative to running Tomcat on port 80, if you have Apache in front of Tomcat, you can use mod_proxy as well as ajp connector to map your domain to your Tomcat application(s) using an Apache vhost as shown below.

While Tomcat has improved it's 'standalone performance', I still prefer to have Apace in front of it for a number of reasons.

In your Apache config, be sure to set KeepAlive to 'on'. Apache tuning, of course, is a whole subject in itself...

Example 1: VHOST with mod_proxy:

<VirtualHost *:80>
    ServerAdmin admin@yourdomain.com
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com

    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
       Order allow,deny
       Allow from all

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    ErrorLog logs/yourdomain.com-error_log
    CustomLog logs/yourdomain.com-access_log common


Example 2: VHOST with ajp connector and mod_proxy:

<VirtualHost *:80>
	ServerAdmin admin@yourdomain.com
	ServerName yourdomain.com
	ServerAlias www.yourdomain.com

	ProxyRequests Off
	ProxyPreserveHost On
	<Proxy *>
	Order allow,deny
	Allow from all

	ProxyPass / ajp://localhost:8009/
	ProxyPassReverse / ajp://localhost:8009/

	ErrorLog logs/yourdomain.com-error_log
	CustomLog logs/yourdomain.com-access_log common

In both vhost examples above, we are "mapping" the domain to Tomcat's ROOT directory.

If we wish to map to an application such as yourdomain.com/myapp, we can add some rewrite as shown below.

This will rewrite all requests for yourdomain.com to yourdomain.com/myapp.

Example 3: VHOST with rewrite:

<VirtualHost *:80>
	ServerAdmin admin@yourdomain.com
	ServerName yourdomain.com
	ServerAlias www.yourdomain.com

	RewriteEngine On
	RewriteRule ^/$ myapp/ [R=301]

	ProxyRequests Off
	ProxyPreserveHost On
	<Proxy *>
	Order allow,deny
	Allow from all

	ProxyPass / ajp://localhost:8009/
	ProxyPassReverse / ajp://localhost:8009/

	ErrorLog logs/yourdomain.com-error_log
	CustomLog logs/yourdomain.com-access_log common

Related Tomcat Posts

Learn More About Apache Tomcat 7 Apache Tomcat Foundation Tomcat 7

Tomcat 7 Hosting

Bookmark and Share


Great step by step, congratulations... Help me so much.

Posted by Pablo Souza on June 01, 2011 at 09:44 AM CDT #

Thanks, Pablo. Glad you found it useful.

Posted by David Ghedini on June 01, 2011 at 09:58 AM CDT #

Thanks, this guide really helped me out.

Posted by Random Reader on June 22, 2011 at 10:40 AM CDT #

Great tutorial, Thanks.

Posted by on June 23, 2011 at 09:31 AM CDT #

+1 to that, really helpful. I've installed solr with tomcat a dozen times or more on Windows but faced with a bare-bones RedHat server and zero linux experience was a bit befuddled. Happily your instructions contain enough detail to get me through even the n00b linux hurdles of making users and groups, chown etc. So big thanks!

Posted by Jeremy on September 07, 2011 at 09:05 AM CDT #

Awesome piece. Straight to the point and on-point. Good one David.

Posted by Babatunde Adeyemi on September 19, 2011 at 12:50 PM CDT #

Thanks a lot David, I followed your guide and everything looks fine.

One question, in the second tomcat init script you changed CATALINA_HOME fro TOMCAT_HOME

. Why was that?, or is irrelevant how it is called?

Posted by Andres Arenas on November 18, 2011 at 09:34 AM CST #

this part not work

i canĀ“t understand

This will create the directory /usr/java/jdk1.7.0

[root@srv6 ~]# cd /usr/java
[root@srv6 java]# sh /opt/jdk-7-linux-x64.tar.gz

Posted by Francisco on December 04, 2011 at 07:16 PM CST #

Hi Francisco -

Please look again at Step 1.

You need to first unpack the file:

[root@srv6 java]# tar -xzf jdk-7u1-linux-x64.tar.gz


Posted by David Ghedini on December 05, 2011 at 03:17 AM CST #

Hi Andres -

Thanks for pointing this out. I have updated both to CATALINA_HOME for consistency.

It does not matter what you call this in the script I included as it is only being used only as shorthand for the path /usr/share/apache-tomcat-7.0.21

You could call it ANDRES_HOME and it would work the same.


Posted by David Ghedini on December 05, 2011 at 03:25 AM CST #

Dear David

I am learning JEE and Ubuntu.

I have installed oracle java successfully (1.7). Downloaded apache-tomcat 7.0.23 .

when i test : service tomcat start i get the following output:

root@anoop-Inspiron-N5010:/usr/share/apache-tomcat-7.0.23/bin# service tomcat start

sh: Can't open /usr/share/apache-tomcat-7.0.19/bin/startup.sh

but when i manually go and type the http://localhost:8080/ i get the apache run page...

i dont know what i have done is correct

Best Regards


Posted by anoop on December 13, 2011 at 10:52 AM CST #

Hi Anoop

Sorry, but I'm not familair with Ubuntu.

What I can see, however, is that you have installed apache-tomcat-7.0.23, but your tomcat script is referencing apache-tomcat-7.0.19

See here:

root@anoop-Inspiron-N5010:/usr/share/apache-tomcat-7.0.23/bin# service tomcat start
sh: Can't open /usr/share/apache-tomcat-7.0.19/bin/startup.sh

Hope that helps some.

For anything more with Ubuntu, I'm afraid I'm quite useless.


Posted by David Ghedini on December 14, 2011 at 06:13 PM CST #

One note: You should not edit catalina.sh to set options! Create a file setenv.sh in the tomcat bin directory were you set all options you need. This file is read by catalina.sh since tomcat5.

Posted by Bertl on December 22, 2011 at 03:08 AM CST #

Hi Bertl -

Its good to note the setenv.sh functionality.

Unless I am working with others and want to keep things tidy, I almost never use it.

Probably lazy, but I prefer adding a couple of lines to an existing file over creating additional files.


Posted by David Ghedini on December 22, 2011 at 09:38 AM CST #

How come you didn't use the rpms?

Posted by Robert Hinson on February 05, 2012 at 06:38 PM CST #

nice tutorial.............thank you so much...........

Posted by Subrata Saha on February 06, 2012 at 03:25 AM CST #

Hi Robert (Hinson)-

The installation is more transparent if you avoid the rpms.


Posted by David Ghedini on February 07, 2012 at 03:43 PM CST #

Great tutorial ! Thank you for ease up my life. :-)

Posted by Dieter on March 02, 2012 at 05:02 AM CST #

Excellent article. No short cuts taken in the explanation....you saved me days of work!

Posted by Noel on March 06, 2012 at 04:35 AM CST #

Brilliant tutorial.
Just a quick note, last stop/start service script is missing /bin before .sh files in their path definition.

Posted by Deniz on March 06, 2012 at 07:46 PM CST #

Hi Deniz -

Glad you found it useful.

The 'sh' is not required in the second script.


Posted by David Ghedini on March 08, 2012 at 04:33 PM CST #

Sorry, let me make myself clear,

in the last stop/start script, e.g. for the line 16, it should be /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh, while it is /bin/su tomcat $CATALINA_HOME/shutdown.sh at the moment.

I hope it makes more sense now.

Posted by Deniz on March 08, 2012 at 04:43 PM CST #

Hi Deniz

If you look at the script, CATALINA_HOME is set to:


So it already includes the /bin directory in the path


Posted by David Ghedini on March 09, 2012 at 06:56 AM CST #

Hi David, The steps were quite clear, unfortunately, I am stuck up at Step 4, last step, I am not getting tomcat home screen after installation. Its just page cannot be displayed like tomcat is not installed at all. Your advice would be highly appreciated. Thanks, Aaron

Posted by Aaron on March 18, 2012 at 09:11 PM CDT #

On step "chkconfig --add tomcat" I get "service tomcat does not support chkconfig" anyone know why?

Posted by Eric Stob on March 23, 2012 at 12:43 PM CDT #

@Aaron -

Firstly, grep to see if tomcat is running.

If so, check that port 8080 (or whichever port you are using) is open.


Posted by David Ghedini on March 24, 2012 at 03:17 PM CDT #

@EricStob -

1. Check that tomcat script is executable.

2. Make sure you have:

# description: Tomcat Start Stop Restart
processname: tomcat
# chkconfig: 234 20 80

At the start of the script.


Posted by David Scott Ghedini on March 24, 2012 at 03:21 PM CDT #

wonderful! optimum.

Posted by Satyajit Chakraborty on April 11, 2012 at 12:31 AM CDT #

thanks! It was very helpful for me.

Posted by nvf on April 23, 2012 at 10:20 AM CDT #

Dear David, You have written an outstanding guide...

Can you also write a guide that shows how to set up multiple virtual hosts in Tomcat- for eg. one web app at http://subdomain1.domain-a.com/ and another web app at http://subdomain2.domain-b.com/ ?

I could not find a good guide that explains setting up Tomcat 7 with multiple virtual hosts.

Or if you could point me to an existing guide that shows how to do this, I would be extremely grateful.


Posted by Arvind IK Chari on May 02, 2012 at 11:03 AM CDT #

Perfect explanation. Thank you so much!!

Posted by Danilo Del Fio on May 06, 2012 at 08:40 PM CDT #

in this step : [root@srv6 init.d]# more /usr/share/apache-tomcat-7.0.29/logs/catalina.out

i get a problem like this :

java.lang.ClassNotFoundException: org.apache.catalina.startup.Catalina
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:236)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:426)
i use centos 5.
please help me

Posted by wajan on August 14, 2012 at 05:33 AM CDT #

Hi Wajan-

I can only see the lines above as my comment system only allows so many lines.

If you can post the full stack on PasteBin or similar, I will be happy to take a look.


Posted by David Ghedini on August 14, 2012 at 06:35 AM CDT #

Hello Devid,
Thanks for your nice article. I have followed your process but I have been facing a problem.
My web server starts with no error and the port 8080 listen but when I give a URL like localhost:8080 but it shows waiting but after few time it shows the connection was reset.
What may be the error for this kind of problem?

Posted by Rajib on August 18, 2012 at 12:33 PM CDT #

Very good this step-by-step.

Posted by Leonardo on August 29, 2012 at 03:39 PM CDT #

Hi Rajib -

After opening 8080 did you save the iptables?


Posted by David Ghedini on August 30, 2012 at 08:01 AM CDT #

Awesome, It was very helpful for me.

Posted by Jaume on September 05, 2012 at 05:12 PM CDT #

Wonderful tutorial! Thank you very much!

Posted by Benedikt on September 07, 2012 at 11:21 AM CDT #

Great tutorial! I've configured tomcat perfectly! Thanks alot!

Posted by renjithkm on September 11, 2012 at 04:42 AM CDT #

Very helpful, thanks a lot!

Posted by Tarun on September 22, 2012 at 05:45 AM CDT #

Very Helpful tutorial :) Thanks.

Posted by Dhiraj on September 29, 2012 at 08:57 AM CDT #

Very helpful dude thanks :)

Posted by Ram on October 11, 2012 at 03:52 AM CDT #

Awesome Article. Explained Step-by-Step wonderfully. Thanks David.

Posted by Arfat on December 04, 2012 at 03:01 AM CST #

Nice tutorial but by tomcat is not running it showing error
Using CLASSPATH: /usr/share/apache-tomcat-7.0.34/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.34/bin/tomcat-juli.jar
/usr/share/apache-tomcat-7.0.34/bin/catalina.sh: line 439: /usr/java/jdk1.7.0_10/bin/java: No such file or directory
But This file exist.
Please suggest me...

Posted by Vivek on December 19, 2012 at 02:44 PM CST #

Wow, thanks for a great tutorial, you saved me hours of trial and error!

Posted by Dottie on December 20, 2012 at 09:19 PM CST #

Perfect tutorial to setup a perfect configured tomcat! Thanks a lot!

Posted by Frank on December 22, 2012 at 08:34 AM CST #

Hi Vivek-
Please show me your start script

Posted by David Ghedini on December 22, 2012 at 07:13 PM CST #

Hi @David thanks for reply, I solved this issue.
I removed installed open JDK using yum remove after that i downloaded rpm file from oracle using wget command then i installed downloaded rpm file using #rpm -i jdk---.rpm
Now Tomcat working fine.
Thanks again for sharing this articles.
Vivekanand Saraswati

Posted by Vivek on December 23, 2012 at 02:04 AM CST #

David, thank you for such perfect explanation!
But I still can't add tomcat to autostart via chkconfig.
My tomcat script is equal to your example:
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig 234 20 80
export JAVA_HOME
export PATH
case $1 in

Posted by Nikita Fyodorov on December 26, 2012 at 08:43 AM CST #

@ Nikita -

If you are unable to add the script to chkconfig, please check that you made the script executable (chmod 755 tomcat.sh).

If executable and you still get an error, try recreating the script using vi as your file may contain problems.


Posted by David Ghedini on December 28, 2012 at 05:38 AM CST #

Hi Vivekanand,

Glad you were able to find the issue.

Thanks for sharing your solution.


Posted by David Ghedini on December 28, 2012 at 05:40 AM CST #

Thanks for the great tutorial man. Worked like a charm

Posted by sumanta on December 29, 2012 at 03:16 AM CST #

I have used your instructions on more than one occasion. Thanks so much for your contribution.

Posted by Vinod on January 17, 2013 at 09:58 PM CST #

Thanks a lot for sharing

Posted by skunked on January 30, 2013 at 07:17 AM CST #

Thanks for this great guide, and I finally got it to start on bootup, but I had to add runtime level 5 with chkconfig --level 2345 tomcat on command. Would this be because the server is stopped when I log onto the X display manager?

Posted by Christopher Wheatley on February 01, 2013 at 10:23 PM CST #

before step 4, when you do http://yourdomain.com:8080.
in CentOS at least if u dont durn off your firewall you cant see it from another computer so if you have a virtual machine like me you just have to do this as root:

# service iptables save
# service iptables stop
# chkconfig iptables off
your manual work for me until this step. so thanks

Posted by White_King on February 15, 2013 at 11:59 AM CST #

Thanks, David

Posted by Maksim Bjelica on February 18, 2013 at 02:29 AM CST #

Hi David,

This is an awesome guide. It helped me a lot.
Tomcat is successfully running on my fedora 14. But I can't access it from a remote windows 7 pc or any other linux pc.
What are step wise configuration procedure to access my tomcat and mysql database from any other remote pc?
My tomcat version is 7.0.37. Port is 8080.
Thanks in advance

Posted by Gourab Das on March 05, 2013 at 12:21 PM CST #

Hi Gourab -

Glad you found it useful.
Check your iptables.
It sounds like port 8080 is not open on your server.


Posted by David Ghedini on March 16, 2013 at 06:00 PM CDT #

Hi White_King

- I would not recommend just stopping your iptables :)

You should add a rule to either open port 8080, or use port 80 (step 7), or use Apache in front (step 8), etc...


Posted by David Ghedini on March 16, 2013 at 06:04 PM CDT #

Thanks David, It helped me alot, KUDOS

Posted by sai on March 21, 2013 at 04:01 AM CDT #

Thanks for that great and very detailed installation how-to!


Posted by Roger on March 27, 2013 at 11:42 AM CDT #

Excellent!! Very helpful. Thank you!!

Posted by Antonio on April 08, 2013 at 09:22 PM CDT #

thanks for the guides ,very useful !

Posted by Boonpin on April 09, 2013 at 01:27 AM CDT #

How can I do this with only secure shell? How can I download?

Posted by Dan Howard on May 15, 2013 at 12:34 PM CDT #

Hi Dan,

You can download Tomcat using wget as shown in Step 2 above.

To download the JDK via terminal, please see my video on downloading from the OTN using wget and Firefox download manager:


Posted by David Ghedini on May 18, 2013 at 01:00 PM CDT #

Thanks I found it. :)

Posted by Dan Howard on May 18, 2013 at 03:54 PM CDT #

Thanks man, great help. Awesome work!. Cheers!!, Fred

Posted by Fred on June 13, 2013 at 04:20 AM CDT #

Really This is very Helpful tutorial for whose first time configuring Apache Tomcat. Thanks a much !!

Posted by Rameshwar on July 11, 2013 at 01:08 AM CDT #

Really, one of the finest tutorials I've come across. Clear, understandable, with good examples for every step.

Posted by Tommy on July 23, 2013 at 10:53 AM CDT #

[root@yomahi ~]# service tomcat start sh: /usr/share/apache-tomcat-7.0.29/bin/startup.sh: No such file or directory [root@yomahi ~]#

Posted by Mahendra on August 05, 2013 at 03:40 AM CDT #

Hi Mahendra,

Is tomcat-7.0.29 the actual version you installed?

Please check if the version in your script matches the version you have unzipped under /usr/share


Posted by David Ghedini on August 05, 2013 at 02:57 PM CDT #

Excellent instructions. Worked perfectly. You rock!

Posted by Ed Connor on August 31, 2013 at 08:20 PM CDT #

CentOS 6 is fully updated, latest versions of Java (jdk-7u25-linux-x64.tar.gz) is installed like you write, same goes for Tomcat7. Tomcat is starting, stopping, and restarting just fine. Firewall is open for 8080. However, it does not pop-up in the browser?!?!? Should be here...

Posted by Henry den Hengst on September 05, 2013 at 09:03 AM CDT #

Thank you for such a thorough and helpful tutorial!

In step 4, one of the new roles is shown as admin-gu. Shouldn't that be admin-gui?

Posted by Mike on September 17, 2013 at 12:43 AM CDT #

Great job David. Your guide is the best. Saved me a lot of time. You are the best. Thanks

Posted by Oskwesi on October 04, 2013 at 05:48 AM CDT #

great tutorial! Wish I had found this one first!

Posted by Scott Brown on November 10, 2013 at 11:37 AM CST #

Great, very clear, thanks David

Posted by Tommy Tran on November 12, 2013 at 09:46 PM CST #

How to change port of Apache Tomcat server ? and How to access tomcat server from remote Machine?( Firewall is already disabled)

Posted by Pramod on November 13, 2013 at 08:48 AM CST #

Thank you. Very clear step-by-step instructions.

Posted by Glitchdata on January 22, 2014 at 10:56 PM CST #

Thank you very much. This is one of the best step-by-step tutorials on the internet. I managed to setup this on my vps flawlessly. God bless you for sharing.

Posted by Samuel Ayela on February 06, 2014 at 11:53 AM CST #

how to separate database server from application server , on different server?

Posted by shree on February 24, 2014 at 03:47 AM CST #

thanks for this great tutorial...!!! just let me know what i have to add in start/stop script so that i can able to check the status through cmd service tomcat status Thanks in advance..!!!!

Posted by vin on March 11, 2014 at 01:51 AM CDT #

Great, however in the docs (RUNNING.TXT in catalina home) says: Note: Do not use JAVA_OPTS to specify memory limits. You do not need much memory for a small process that is used to stop Tomcat. Those settings belong to CATALINA_OPTS.

Posted by Bart on April 29, 2014 at 03:30 PM CDT #

Hi, its really helpful to me and our team...

Posted by thelinuxfaq.com on October 29, 2014 at 07:21 AM CDT #

Hi,because I set the CATALINA_HOME and JAVA_HOME to the /etc/profile, so I deleted the
export JAVA_HOME
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.29/bin ".

But when I excute "service tomcat start",it display "sh: /bin/startup.sh: No such file or directory". It looks like, the shell can not read the "CATALINA_HOME" variable. Why? Thank you verymuch!

Posted by solo on December 07, 2014 at 12:26 PM CST #

Hi solo,

Check the bash profile for root and ensure it has the appropriate paths set

If you are running as minimal user tomcat (Step 6 above), you still need to issue stop/start/restart as root.

Posted by David Ghedini on December 17, 2014 at 04:26 PM CST #

Very good documentation indeed. Compliments.

Do you have information on how Tomcat services can be managed by admin panel such as Plesk version 12. (sp.parallels.com/products/plesk/)

I installed Tomcat 7 using your steps and it was succssful upto step 3. Tomcat is running and I checked it using www.tld.nn:8080

Now, how do I tell Plesk that I have installed Tomcat 7. Current implementation of Plesk is configured with Tomcat 6.

I could not find enough resource on Plesk forums on this subject.

Posted by Vinod Vyas on February 08, 2015 at 03:16 AM CST #

It works very well. Thanks!!!

Posted by Rodrigo Deus on February 19, 2015 at 01:06 PM CST #

Thanks!!! Great step by step!!! Help me so much. :)

Posted by Luster timber on February 25, 2015 at 04:37 AM CST #

Thanks for your guide. I am not a Java guy. But your tutorial really helped me a lot to setup a server for a friend.

Posted by Varun Sikka on July 20, 2015 at 03:11 AM CDT #

Thanks David, proxy and rewrite from apache to tomcat helped ! Regards AB

Posted by ABD on October 22, 2015 at 10:50 PM CDT #

thanks for the information provided. It was very useful.

Posted by Ashok on October 29, 2015 at 11:15 AM CDT #

I think CATALINA_OPTS is better than JAVA_OPTS for Heap memory settings (Stop 6).

catalina.sh comment is like this:

# CATALINA_OPTS (Optional) Java runtime options used when the "start",
# "run" or "debug" command is executed.
# Include here and not in JAVA_OPTS all options, that should
# only be used by Tomcat itself, not by the stop process,
# the version command etc.
# Examples are heap size, GC logging, JMX ports etc.

Posted by Shin Sang-jae on November 18, 2015 at 09:38 PM CST #

Typo in the last code snippet of Step 6:


"/bin" should be removed.

I'm quite sure you have the best step-by-step tutorial of this kind! Thank you immensely!

Posted by David on December 01, 2015 at 11:55 PM CST #

Hi David -

Thanks for catching this.

I have updated step 6.


Posted by David Ghedini on December 07, 2015 at 10:41 AM CST #

Such a useful and well written tutorial. Thank you so much for this! You're a life saver.

Posted by Kevin Vaccaro on January 07, 2016 at 02:47 PM CST #

Post a Comment:
  • HTML Syntax: Allowed

Main Menu

Built With




Tag Cloud

Hosted by:





petiole Cloud