Tomcat Servlet Engine

Aus Peter Fuerholz' Wiki
Zur Navigation springen Zur Suche springen

Installing Tomcat on Ubuntu

(Based mainly on [1].)

  1. Download preferred version (e.g. 6.0.35) from [2]
  2. Issue:
    tar xvzf apache-tomcat-6.0.35.tar.gz
    sudo mv apache-tomcat-6.0.35 /usr/local/tomcat
  3. Open browser with: http://localhost:8080/: You should see "It works." -> Tomcat get automatically started after installation.
  4. Configure users with 'sudo gedit /etc/tomcat6/tomcat-users.xml':
 <role rolename="manager"/>
 <user username="mgr" password="*****" roles="manager"/>
 <role rolename="admin"/>
 <user username="adm" password="*****" roles="admin"/>
 <role rolename="user"/>
 <user username="user1" password="*****" roles="user"/>

Starting / Stopping

 /usr/local/tomcat/bin/startup.sh
 /usr/local/tomcat/bin/shutdown.sh

Files / Directories (on Ubuntu Linux)

All important files are under /usr/local/tomcat:

  • Log: /logs
  • Configuration: /config
  • Application context files go to: /conf/Catalina/localhost
  • Deploy directory: /webapps

Don't save session persistently

  • Go to context.xml (withing /usr/local/tomcat/conf) and uncomment following text:

   <Manager pathname="" />


Sending Emails

See Apache Tomcat 7 documentation. I have done it like this:

  1. Downloaded JavaMail-libs from [4] (v.1.5.1)
  2. Copied javax.mail-1.5.1.jar to pfu/tomcat/lib

DEPRECATED FOR SW-DEVELOPMENT (Does not work properly together with Eclipse):Installing Tomcat on Ubuntu from Repositories

There are hundreds of installation guides for Tomcat. I found a good one here. What I did in my case:

  1. Synaptic Package Manager: Install packages: tomcat6, tomcat6-admin, tomcat6-docs (and all linked packages)
  2. Optional steps:
    1. Edit /etc/default/tomcat6 and set JAVA_HOME=/usr/lib/jvm/java-6-sun (Otherwise Open-JDK-version will be used.)
    2. Restart Tomcat: sudo /etc/init.d/tomcat6 restart
    3. Add JAVA_OPTS="-Djava.net.preferIPv4Stack=true" to /etc/default/tomcat6: See [5]
  3. Open browser with: http://localhost:8080/: You should see "It works." -> Tomcat get automatically started after installation.
  4. Configure users with 'sudo gedit /etc/tomcat6/tomcat-users.xml':
 <role rolename="manager"/>
 <user username="mgr" password="*****" roles="manager"/>
 
 <role rolename="admin"/>
 <user username="adm" password="*****" roles="admin"/>
 
 <role rolename="user"/>
 <user username="user1" password="*****" roles="user"/>

Starting / Stopping

 sudo /etc/init.d/tomcat6 start
 sudo /etc/init.d/tomcat6 stop

or

 /usr/share/tomcat6/bin/startup.sh
 /usr/share/tomcat6/bin/shutdown.sh

Files / Directories (on Ubuntu Linux)

  • Log: /var/log/tomcat6
  • Configuration: /etc/tomcat6: server.xml, tomcat-users.xml, context.xml, logging.properties, web.xml
  • Application context files go to: /etc/tomcat6/Catalina/localhost
  • Default configuration: /etc/default/tomcat6
  • Deploy directory: /usr/share/tomcat6/webapps
  • Program: /usr/share/tomcat6 / /usr/share/tomcat6-admin / /usr/share/tomcat6-docs / /usr/share/tomcat6-examples

Setting up HTTPS

See [6]
Coarsely describen: (__TODO__)

  1. Create key-file (.bin) using JDK's keytool and place next to / into Tomcat directory
  2. Configure connector in server.xml referencing the bin-file.
  3. Configure your web application (web.xml) configuring if the application shall be accessible only <transport-garantee>CONFIDENTIAL</transport-garantee>.