Installing Apache2 and Tomcat6 with mod_jk on Ubuntu 10.10

Use case

This brief step-by-step guide tries to explain how to install Tomcat with Apache and mod_jk on an Ubuntu 10.10 system considering following components

Apache 2, MySQL 5, PHP 5, PhpMyAdmin, Sun Java JDK 1.6, Tomcat 6.0, Tomcat-Admin, mod_jk

Update: Since the Java installation changed during the latest Ubuntu releases, the Java installation routine might be outdated. Please read this post for updated instructions.

LAMP – Apache, MySQL, PHP

$ sudo apt-get install tasksel
$ sudo tasksel

Remember your MySQL password.
Now create a test page

$ sudo nano /var/www/info.php

and insert following code


Restart Apache

/etc/init.d/apache2  restart

and check if everything went fine

$ wget http://[MY_IP]/info.php


Install via apt-get

$ sudo apt-get install phpmyadmin

Choose Apache, and insert credentials

Now create a soft-link to make phpmyadmin-sources available in /var/www

$ sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Now open a browser and see if it’s working


(use the credentials you defined shortly before)


Since Sun’s java is not provided by the repository anymore, we have to add it manually:

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6
$ sudo apt-get install sun-java6-jdk

Usually this should be already everything what we have to do. Try it by typing

$ sudo java -version


Install both tomcat-common and tomcat-admin via apt-get

$ sudo apt-get install tomcat6
$ sudo apt-get install tomcat6-admin

For accessing the Tomcat-admin we need to add our own manager-user

$sudo nano /etc/tomcat6/tomcat-users.xml

And add the new user

<user username="admin" password="my_secret" roles="manager"/>

Finally restart Tomcat

$ sudo /etc/init.d/tomcat6 restart

Try if it works


Mod JK

Install via apt-get

$ sudo apt-get install libapache2-mod-jk

Now create our own file for Apache.
Open or create

$ sudo nano /etc/apache2/

and paste:

# Define 1 real worker using ajp13
# Set properties for worker1 (ajp13)

Now tell the Apache to use this worker

$ sudo nano /etc/apache2/apache2.conf

and add following lines

JkWorkersFile /etc/apache2/
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

Finally configure which URLs Apache should pass through the Tomcat

$ sudo nano /etc/apache2/sites-enabled/000-default
JkMount /mytomcatwebappname* worker1

This means, that every URL that contains the key mytomcatwebappname gets handled by Tomcat instead of Apache.

If you want to pass all requests to the Apache (instead of individual ones), just remove the line

DocumentRoot /var/www

and add following JkMounts:

JkMount / worker1
JkMount /* worker1

And last but not least, we have to enable the redirect port 8443 on Tomcat

$ sudo nano  /etc/tomcat6/server.xml

And uncomment / insert / update that following line is present

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Now we only have to restart first the Tomcat and then the Apache

$ sudo /etc/init.d/tomcat6 restart
$ sudo /etc/init.d/apache2 restart
Tagged with: , , , ,
Posted in Java, Uncategorized, Webserver
18 comments on “Installing Apache2 and Tomcat6 with mod_jk on Ubuntu 10.10
  1. Commonality with specific Windows errands is required to introduce and arrange ArcIMS. For subtle elements, see the accompanying ESRI Knowledge Base article, Common Windows assignments when introducing ArcIMS.

  2. Felipe says:


    Helped me a lot =)

  3. Karthik says:

    Thanking You Sir ….

    Really nice…

    Its Work 100%….

    Thank u very much….

  4. Rafael ROman says:

    You sir is a hero!

  5. Eduardo says:

    Worked perfectly for me! I just had to rename the /etc/apache2/mod-enabled/jk.conf file as Amy suggested.
    Tks a lot!!

  6. Kumar says:

    # /etc/init.d/apache2 start
    * Starting web server apache2 Syntax error on line 232 of /etc/apache2/apache2.conf:
    JkWorkersFile only allowed once
    Action ‘start’ failed.
    The Apache error log may have more information

    Changes in the view source
    sudo nano /etc/apache2/sites-enabled/000-default

    just added

    ServerAdmin webmaster@localhost

    JkMount / worker1
    JkMount /* worker1

    Options FollowSymLinks
    AllowOverride None

    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all


    Could you please help me on this?

    • admin says:

      Looks like you have configured the JkWorkersFile property twice – though the 000-default configuration looks fine.
      What does the apache error log says exactly?

    • Amy says:

      I was challedged by same error. But I managed to solve the problem.

      If you search for the ‘’ file you shoud find out that another ‘worker.proprties’ is configured in /etc/apache2/mod-enabled/jk.conf.

      Just rename jk.conf to whatever and restart Apache.

  7. RUSUA says:

    Thanks a lot! Very useful post! You helped me to solve my problem with VirtualHost tomcat6-to-apache)))

  8. Marco says:

    Hey guys, nice tutorial, but i think i’ve got some problems with the ajp protocol.
    I can execute .jsp pages with apache and tomcat using mod_proxy with an http connector, but if i try to do the same with ajp and mod_jk i get un-executed .jsp codelines.
    Any ideas?

  9. Harold Da Costa says:

    The best tuto ever!!!!!

  10. Frell says:

    you made me the happiest man in the world!!!

    Thanks for the tutorial.

  11. michael says:

    I am using Ubuntu 10.10 LAMP with latest updates from the repo’s and I followed your instructions on 4 different attempts and I cannot get this to work with this package from sourceforge:

    I get this error after I deploy the app and try to get it to start:
    FAIL – Application at context path /CM-0.2 could not be started

    And there are no logs in /var/log/tomcat6/

  12. Era says:

    Woah! I’m really enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between user friendliness and visual appeal. I must say you’ve done a amazing job with this. Additionally, the blog loads very quick for me on Safari. Excellent Blog!

  13. seedbox says:

    nice share :) :) :)

3 Pings/Trackbacks for "Installing Apache2 and Tomcat6 with mod_jk on Ubuntu 10.10"
  1. [...] handling changed during the last Ubuntu releases due to Oracle’s politics (and most parts of my old post are out of date), I found a great instruction about how to install Oracle’s Java JDK on [...]

Leave a Reply

Your email address will not be published. Required fields are marked *


Anti-spam protection

Prove that you are Human by typing the emphasized characters:

Protected by Gab Captcha 2

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