How to install Tomcat 7.0.42 on Ubuntu 12.04.3 LTS?

35,723

Yes, it is possible to install Tomcat 7.0.42, but you'll have to do it "manually".Here are steps on how to do so:

Note: visit this question if you want to know why it's not in the repositories: Why don't the Ubuntu repositories have the latest versions of software?

Prerequisite: you need to have Java installed, and we need its path. Java is usually installed under /usr/lib/jvm. Once you have installed Java, you can run the command update-alternatives --config java to show you the exact path; look at the first entry (the one with a * next to it. You can hit Enter to exit this screen). We only need the directory after /jvm/. On my machine, the directory was /usr/lib/jvm/java-7-openjdk-i386/. This answer will assume that this is the Java directory, but you should change the commands accordingly.

  1. wget http://mirror.atlanticmetro.net/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz

    • This will download Tomcat 7.0.42 to your current directory.
  2. tar xzvf apache-tomcat-7.0.42.tar.gz

    • This will extract the files.
  3. sudo mv apache-tomcat-7.0.42 /usr/local

    • This moves Tomcat to /usr/local. You can choose any path you want. The remaining commands will assume you have used this path.
  4. nano ~/.bashrc - this will open up a text editor. Go to the end of the file (Alt+/) and add the following two lines:

    export CATALINA_HOME=/usr/local/apache-tomcat-7.0.42
    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
    

    Remember: this was the path to my Java. Change it to your installed Java.

  5. . ~/.bashrc

    • This will apply the changes we made.
  6. sudo $CATALINA_HOME/bin/startup.sh - you should see something like this:

    Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.42
    Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.42
    Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.42/temp
    Using JRE_HOME:        /usr
    Using CLASSPATH:       /usr/local/apache-tomcat-7.0.42/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.42/bin/tomcat-juli.jar
    

    And no errors.

You're done. Point your browser to http://localhost:8080 and you should see the Tomcat page:

Share:
35,723

Related videos on Youtube

Trovs
Author by

Trovs

Updated on September 18, 2022

Comments

  • Trovs
    Trovs almost 2 years

    The sysadmin gave me a virtual machine which I access through terminal.

    I have root access and it got Ubuntu 12.04.3 LTS.

    The command apt-cache policy tomcat7 informs:

    tomcat7:
      Installed: (none)
      Candidate: 7.0.26-1ubuntu1.2
      Version table:
         7.0.26-1ubuntu1.2 0
            500 http://br.archive.ubuntu.com/ubuntu/ precise-updates/universe amd64 Packages
            500 http://security.ubuntu.com/ubuntu/ precise-security/universe amd64 Packages
         7.0.26-1ubuntu1 0
            500 http://br.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
    root@mymachine:~#
    

    However, I'd like to install the latest Tomcat 7 (7.0.42) on it.

    Is it doable? If yes, how?

  • dShringi
    dShringi over 10 years
    +1 for the beautiful answer, thanks for the effort !
  • Pragatheeswaran
    Pragatheeswaran over 10 years
    Exact explanation which a basic user can also follow. Nice Job.
  • mau
    mau about 10 years
    This was such an amazing explanation. Couldn't make IntelliJ to work, now it is possible. You rock!