Debian Admin

Debian/Ubuntu Linux System Administration Tutorials,Howtos,Tips

  • Sponsor

  • Categories

  • Sponsor

  • Meta

  • Archives

How to setup Apache Tomcat 5.5 on Debian Etch

Posted by Admin on November 27th, 2007

Apache Tomcat is a web container, or application server developed at the Apache Software Foundation (ASF). Tomcat implements the servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, providing an environment for Java code to run in cooperation with a web server. It adds tools for configuration and management but can also be configured by editing configuration files that are normally XML-formatted. Tomcat includes its own internal HTTP server.

First Sun JDK 5 need to be installed. It can be installed from Debian repository with unstable software

First you need to edit /etc/apt/sources.list file

#vi /etc/apt/sources.list

Add the following lines

# for sun-java packages in unstable
deb http://ftp.debian.org/debian/ unstable non-free
deb-src http://ftp.debian.org/debian/ unstable non-free

Save and exit the file.

Now you need to Update apt using the following command

#apt-get update

Install jdk using the following command

#apt-get install sun-java5-jdk

Check the java version using the following command

#java -version

Output looks similar to the following

java version “1.5.0_10″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)

Installing Apache Tomcat

Install Tomcat using the following commands

#apt-get install tomcat5.5
#apt-get install tomcat5.5-admin
#apt-get install tomcat5.5-webapps

To verify that Tomcat is running just navigate to http://localhost:8180/ in your browser (make sure you have replaced ‘localhost’ with your server ip or name)

You can start/stop or restart Tomcat using following command:

#/etc/init.d/tomcat5.5 [start | stop | restart]

Configuring ‘admin’ and ‘manager’ applications

You need to configure some user to have admin and manager roles. For example you can do it with ‘tomcat’ user. Stop server using the following command.

#/etc/init.d/tomcat5.5 stop

Now you need to edit /var/lib/tomcat5.5/conf/tomcat-users.xml file to look like below

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="tomcat"/>
<user username="tomcat"
password=”tomcatpassword”
roles="tomcat,admin,manager"/>
</tomcat-users>

Save and exit the file.

Start tomcat using the following command

#/etc/init.d/tomcat5.5 start

Now you can use manager application at http://localhost:8180/manager/html.
Your user will be ‘tomcat’ and password will be ‘tomcatpassword’

  • Share/Bookmark

16 Responses to “How to setup Apache Tomcat 5.5 on Debian Etch”

  1. Yong Says:

    I followded those instructions and was able to run tomcat admin/manager (great!!!).
    But when I deployed my web app, the app failed to start. The only error I can see in catalina.log is:
    SEVERE: Error listenerStart

    How can I get more details about what causes the failure???

    Thanks!

    -Yong

  2. Miguel Says:

    Great job. It worked.

    Thanx.

  3. Ann Says:

    Thank you for making it SUPER easy to set up my Linux server!
    This page alone saved me heaps of headaches

  4. brndnbg Says:

    I would like to annotate that althoug this solution works to get your admin-page, you will not be able to deploy war-archives to the server. To be able to do that, you will have to modify the file “/etc/tomcat5.5/policy.d/04webapps.policy” and find the following block:

    grant codeBase “file:${catalina.home}/bin/tomcat-juli.jar” {
    //some permissions here
    [...]

    };

    then you add the followin line to the other permissions in the block and fill in your webapps name:

    permission java.io.FilePermission “/var/lib/tomcat5.5/webapps/<>/WEB-INF/classes/logging.properties”, “read”;

    This is a nasty task and took me quite a few hours on “grepping” through logfiles and googling. It should be done automatically by tomcat. Has anyone a better solution? I’m still a novice in this J2EE thing.

    Greets.

  5. brndnbg Says:

    seems like the doubled angle brackets where interpreted as comments or something. You have to insert your webapps name between ““/var/lib/tomcat5.5/webapps/” and “/WEB-INF/classes/logging.properties” ;-)

  6. pj Says:

    Thanks,

    Piece of cake with this HowTo

  7. Thanks Says:

    I hava searched for many websites to install the tomcat to my Ubuntu8.04 before I seen your page ,but all fail ! Then I do as your says ,now ,I finally can open the page “http://localhost:8180″ ,Thank you very much ! Good luck with you ! The late success is exciting !!!!!!!!

  8. Kees Says:

    Ps. tomcat had problems with your tomcat-user.xml file. My /var/lib/tomcat5.5/conf/tomcat-users.xml looks like:

    User ad can then login to both the admin and the manager part of tomcat.
    See http://www.netadmintools.com/art340.html

  9. Kasidit Says:

    Thanks very very much!

  10. Yann Says:

    Hi,

    I just installed tomcat5.5 on debian server 40r6, with:
    aptitude install sun-java5-jre
    aptitude install tomcat5.5 tomcat5.5-admin tomcat5.5-webapps

    It is then available from http://localhost:8180/, as well as the Tomcat Manager (http://localhost:8180/manager/html). So far, so good.

    Then I create a dummy HTML file I want to see when calling http://localhost:8180/foo.html, I have to put it there:
    /usr/share/tomcat5.5-webapps/ROOT/foo.html

    If I put a WAR file in this directory, it is automatically expanded:
    /var/lib/tomcat5.5/webapps/

    BUT the problem is that:
    1. it does not show up in the “Tomcat Web Application Manager” page
    2. it is not reachable by http://localhost:8180/

    If I deploy a WAR using the “Tomcat Web Application Manager”, it is then available in /var/lib/tomcat5.5/webapps, but not shown in the Manager page.

    What’s the problem?
    It seems I have 2 webapps directories, instead of one.

    How can I solve that?

    Thanks

  11. Stacy Says:

    Yann, I had the same problem. If you look at the catalina log file you see a logging.properties exception when tomcat is trying to load your app. The fix is described by brndnbg above.

  12. zito Says:

    hi

    very good, wonderfull, you do help me

    thanks

  13. akram Says:

    you may need #chmod +x -R tomcat5.5/

  14. John Says:

    I just used this tutorial on the fresh installation of Lenny without problems, the only thing was to add:

    grant {
    permission java.security.AllPermission;
    };

    to “/etc/java-6-sun/security/java.policy”

    I have no idea whether it’s the right solution, but it works :)

    But how is it with some mods etc? Isn’t it better to use apache2 + libapache2-mod-jk instead of the built-in web server in Apache Tomcat?

  15. Alphonse Says:

    I also used this tutorial to get to the admin-page but could not deploy war-archives (orbeon forms in my case). Changing from java-6-sun to java-6-openjdk did not bear fruit. Disabling the java security option in tomcat5.5 startup script and restarting tomcat5.5. did the trick. i.e.

    Edit /etc/init.d/tomcat5.5 and change TOMCAT5_SECURITY from ‘yes’ to ‘no’

    # Use the Java security manager? (yes/no)
    TOMCAT5_SECURITY=no

    Good Luck!
    My System
    Debian Lenny 5.0 amd64

    neptune:~# uname -a
    Linux neptune 2.6.28.7 #1 SMP Wed Mar 4 19:50:38 EAT 2009 x86_64 GNU/Linux
    astonish:~#

    neptune:~# java -version
    java version “1.6.0_0″
    OpenJDK Runtime Environment (build 1.6.0_0-b11)
    OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)
    neptune:~#

  16. Robert Says:

    Hey

    ok sorry, but i try all opinions what your say.
    i set the TOMCAT5_SECURITY to “no”,
    i add the permission “permission java.io.FilePermission “/var/lib/tomcat5.5/webapps/geoserver/WEB-INF/classes/logging.properties”, “read”;” to /policy.d/04.webapps.policy

    and restart the tomcat5.5.

    i use debian lenny, java-5-jdk, tomcat5.5 and try to start geoserver.
    But when i try to start it with the manager follow message comes: “FAIL – Application at context path /geoserver could not be started

    excuse my bad english.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>