Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Which way should I install Apache Tomcat 7 on my Ubuntu:

  1. Using sudo apt-get install tomcat7
  2. From the zip file downloaded from Apache website.

I don't want the server to start on each boot. As most of the time I will be using it in my Eclipse to run simple Web applications. So, do I need to install it any other way to avoid tomcat start automatically?

share|improve this question

4 Answers 4

up vote 7 down vote accepted

You can use sudo apt-get install tomcat7 to install Tomcat.

To disable autostarting, run the following command after installing:

sudo update-rc.d tomcat7 disable
share|improve this answer
    
Do I need to do some configuration in Tomcat? And where should I start tomcat from manually? –  Rohit Jain Jun 20 '13 at 20:38
    
Not if you use apt-get. –  green7 Jun 20 '13 at 20:43
    
thanks for your answer :) –  Rohit Jain Jun 20 '13 at 20:51

Here's the way I did it, it keeps the system tomcat and your own personal tomcat instance separate.

Install tomcat as per normal: sudo apt-get install tomcat7

Install private instance support: sudo apt-get install tomcat7-user

Create local instance in your home folder:

tomcat7-instance-create -p 10080 -c 10005 mytomcat

Note: -p sets the port number (default is 8080) and -c is the control port (default 8005), we set these so we don't compete with the main installation of tomcat running as a service. "mytomcat" can be anything you like, but it will create a directory by this name in your home.

Now use the following to make Eclipse happy:

cd mytomcat
ln -s /usr/share/tomcat7/lib
ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
ln -s /usr/share/tomcat7/bin/bootstrap.jar bin/bootstrap.jar
ln -s /usr/share/tomcat7/bin/tomcat-juli.jar bin/tomcat-juli.jar
mkdir -p common/classes;
mkdir -p server/classes;
mkdir -p shared/classes;

Now within Eclipse you can create a Tomcat v7.0 server and set the installation directory as ~/mytomcat.

Note: common, server and shared classes could be links too, but I wanted to keep the two separate.

share|improve this answer

NB: This answer was written based on using Tomcat6. I need to update it based on having actually tried using Tomcat 7. See Cannot start tomcat after installing a private instance.

All software is different, obviously, but in general packaged software is quicker and easier to install than zipped distributions. It allows you to configure, start, and stop services in a fairly standard way, and if you run Ubuntu on your production environment it allows you to run consistent versions to minimise compatibility issues. It also allows you to receive security updates automatically.

For Tomcat, it is pretty easy to download the zip distribution, unpack, and point Eclipse at it. However, if you want to keep it updated you'll need to manage that yourself. If you install the packaged version, you'll get updates automatically.

When using Tomcat for development, there are a few problems with installing the tomcat7 package because it is intended to be run as a background service owned by the tomcat7 user:

  1. The installation directories and files are not set up in the way that Eclipse expects; they are split into two locations.
  2. When you run Tomcat from Eclipse it won't have permissions to write to the places it wants to because the files are not owned by your user.
  3. Using sudo update-rc.d tomcat7 disable to prevent the service from starting is not persistent across updates, so if the tomcat7 package gets updated then it'll start up automatically next time you boot.

However, if you only want Tomcat installed for development, and you do not want to run it as a service in the background all the time, there is better alternative for this exact purpose; there is a package specifically for creating private instances. This way, you get the benefit of a packaged distribution, but without the disadvantages of battling with a configuration that is designed to be run as a service.

  1. Uninstall tomcat7 and install the tomcat7-user package instead:

    sudo apt-get install tomcat7-user

  2. Create your own private instance somewhere in your home directory:

    tomcat7-instance-create ~/my-instance

  3. Configure your Eclipse project to use the Tomcat installation in the location you just created above.

Now you can start and stop your own private instance of Tomcat from within your Eclipse project.

TL;DR

  • Don't install tomcat7 for development, use tomcat7-user instead.
  • Download the zip distribution if you're a traditionalist or like doing things the hard way.
share|improve this answer
    
Hi David. How can I configure Eclipse to use my tomcat instance. Do I need to give path of the tomcat instance, or path where tomcat is installed? –  Rohit Jain Jun 26 '13 at 19:42
    
@RohitJain This is a potentially complex question to answer depending on what version of Eclipse you are running and how you installed it. If you create a new question for this with those details, I will try to answer fully. –  David Edwards Jun 26 '13 at 20:51
    
Already Did. A big one. :) –  Rohit Jain Jun 26 '13 at 20:53

In my experience you should only use the officially packaged components for production use. For development I would recommend getting the bits you need directly from the net and install them where you need it.

Then when you are done developing, deploy to the officially packaged Tomcat.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.