A computer science undergraduate at University of Colombo. Pavithra is a DZone MVB and is not an employee of DZone and has posted 16 posts at DZone. You can read more from them at their website. View Full User Profile

Installing Tomcat 7 on Ubuntu 12.04

08.31.2012
| 27444 views |
  • submit to reddit
This post is about installing Apache Tomcat7 on Ubuntu 12.04. Before this installation make sure java is installed in your machine. You can refer this post if you haven't done that already.
  1. Download Tomcat 7 tar.gz binary distribution from here.
  2. Unpack it using following command.
        tar xvzf apache-tomcat-7.0.29.tar.gz   
  3. Move it to a more appropriate location using following command.
        sudo mv apache-tomcat-7.0.29/ /usr/share/tomcat7  
  4. Open up /usr/share/tomcat7/bin/catalina.sh file using following command
        gedit /usr/share/tomcat7/bin/catalina.sh   
  5. Add following two lines in there after the first line.
    JAVA_HOME="/usr/lib/jvm/jdk-6u32"  
    JRE_HOME="/usr/lib/jvm/jdk-6u32/jre"
  6. Open up /usr/share/tomcat7/conf/tomcat-users.xml and uncomment user and role entries there. Then add a manager-gui role and a user by adding following lines there.
        <role rolename="manager-gui"/>  
        <user username="pavithra" password="tomcat" roles="manager-gui"/>  
  7. Start the Tomcat server using following command.
        sudo /usr/share/tomcat7/bin/catalina.sh run  
  8. Verify Tomcat installation using the following URL.
        http://127.0.0.1:8080/  
  9. To login as the manager, use the following URL, provide the relevant username and password.
        http://127.0.0.1:8080/manager/html  
Published at DZone with permission of Pavithra Gunasekara, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Wujek Srujek replied on Sat, 2012/09/01 - 11:35am

What't the point of this post being on the first page on Javalobby? Comon, it's not even correct. One of the first lines in catalina.sh says:

#   Do not set the variables in this script. Instead put them into a script

#   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.

 

Please correct this. 

Stephane Vaucher replied on Sat, 2012/09/01 - 7:25pm

"sudo /usr/share/tomcat7/bin/catalina.sh run"?

 

That would run tomcat as a superuser... Running a web server as root is not a correct installation because it is unsafe.

Patrick Carroll replied on Tue, 2013/03/26 - 1:01pm

 Maybe the "/usr/share/tomcat7" should be a softlink.  That way you can add newer versions of tomcat, move configuration information, change the link, and then delete older versions when you're sure the newer version is working correctly.

It's more of a convenience thing, I suppose

Jamie Krug replied on Tue, 2013/05/21 - 10:25am

I'm perplexed by this post. Why would you go through all this effort, just to run Tomcat as root, without easy updates, and without a more robust init script, when you can just do the following?

sudo apt-get install tomcat7

Kamasula Banda replied on Mon, 2014/02/24 - 7:03am

Hi all, I have been trying to make this installation, I have followed several instructions, but with this one I got stuck at  #7, do I create these files manually or is there something I should do?

bin/catalina.sh run
Using CATALINA_BASE:   /usr/share/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-6-openjdk-i386/jre
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Feb 24, 2014 1:24:59 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:24:59 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:25:00 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:25:00 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:25:00 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:25:00 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Feb 24, 2014 1:25:01 PM org.apache.catalina.startup.Catalina load
WARNING: Unable to load server configuration from [/usr/share/tomcat7/conf/server.xml]
Feb 24, 2014 1:25:01 PM org.apache.catalina.startup.Catalina load
WARNING: Unable to load server configuration from [/usr/share/tomcat7/conf/server.xml]
Feb 24, 2014 1:25:01 PM org.apache.catalina.startup.Catalina start
SEVERE: Cannot start server. Server instance is not configured.

Jamie Krug replied on Mon, 2014/02/24 - 8:08am in response to: Kamasula Banda

@Kamasula, please see my previous comment. This article makes no sense whatsoever. You can do this all with a single command, and have a much more secure configuration with a much more intelligent control script.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.