Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

VirtualHosts,OpenBlueDragon with Tomcat 5.5, Apache2 (mod_jk) on Debian Etch

NewAtlanta announced in March, that they will publish an OpenSource version of the BlueDragon ColdFusion server. Integrating OpenBlueDragon into the classic Linux/MySQL environment, will be a real alternative to PHP (LAMP) webservers.

This howto describes how you can install OpenBlueDragon with Tomcat 5.5 on Debian Etch. The Tomcat server will be connected with mod_jk with the Apache2 webserver.

You can use this howto without the OpenBlueDragon parts to install an Tomcat server together with Apache2.

There are a few reasons to install Tomcat with Apache2. You can use Apache to buffer slow connections, take advantage of Apache features such as cgi and PHP, use Apache modules such as mod_rewrite or you can isolate virtual hosts in their own Tomcat instances.

For the Tomcat installation you need the Sun Java JDK. You have to edit /etc/apt/sources.list and add the “non-free” pakets:

deb http://ftp.debian.org/debian/ main non-free
deb-src http://ftp.debian.org/debian/ main non-free

Now you can install the Sun Java JDK:

# aptitude update
# aptitude install sun-java5-jdk

After that you can install the Tomcat server:

# aptitude install tomcat5.5 tomcat5.5-admin tomcat5.5-webapps

You can test the installation with this URL: http://SERVER:8180

The next step is to configurate the users for the Tomcat management:

# /etc/init.d/tomcat5.5 stop
# vim /var/lib/tomcat5.5/conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="tomcat"/>
<user username="admin"
password="foobar"
roles="tomcat,admin,manager"/>
</tomcat-users>

# vim /etc/default/tomcat5.5
TOMCAT5_SECURITY=no
# /etc/init.d/tomcat5.5 start

Of course you have to change the password to your own one. You need the TOMCAT5_SECURITY setting only for the Tomcat administraton webinterface. If you don’t need the administration, you can keep the setting or restore it if you have finished the configuration.

Now you can use the Tomcat manager application with this URL: http://SERVER:8180/manager/html and the administrator with this URL: http://SERVER:8180/admin

You will find a deploy section in the manager. There you can upload and deploy the openbluedragon.war file.

After the restart of the Tomcat server with “/etc/init.d/tomcat5.5 restart” you will find openbluedragon in the application list of the Tomcat manager.

Installation of the Apache2 Tomcat connector:

# aptitude install apache2 libapache2-mod-jk
# vim /etc/apache2/workers.properties

workers.tomcat_home=/usr/share/tomcat5.5
workers.java_home=/usr/lib/jvm/java-1.5.0-sun-1.5.0.14
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
JK Konfigurationsdatai
# vim /etc/apache2/conf.d/jk.conf
<IfModule mod_jk.c>
    JkWorkersFile /etc/apache2/workers.properties
    JkLogFile /var/log/apache2/mod_jk.log
    JkLogLevel error
</IfModule>
# /etc/init.d/apache2 stop
# /etc/init.d/tomcat5.5 restart
# /etc/init.d/apache2 start

Creating a new VirtualHost: (In Apache AND Tomcat)

Prepare directories:

# mkdir /var/www/vhost1
# mkdir /var/www/vhost1/htdocs
# mkdir /var/www/vhost1/logs

Copy WEB-INF:

# cp /var/lib/tomcat5.5/webapps/openbluedragon/WEB-INF /var/www/vhost1/htdocs/

Creating Apache VirtualHost:

# vim /etc/apache2/sites-available/vhost1
<VirtualHost www.testsrv.local>
    JkMount /*.cfm default
    JkMount /*.cfc default
    JkMount /*.jsp default
    ServerName www.testsrv.local
    ServerAdmin servermaster@testsrv.local
    DocumentRoot /var/www/vhost1/htdocs
    ErrorLog /var/www/vhost1/logs/error.log
    CustomLog /var/www/vhost1/logs/access.log common
    <Location /WEB-INF/ >
      AllowOverride None
      deny from all
    </Location>
</VirtualHost>
# a2ensite vhost1
# /etc/init.d/apache2 reload

Note: You can forward all files “JkMount /*” or all files in a folder “JkMount /folder/*” to the Tomcat, too.

Creating Tomcat host:

# vim /etc/tomcat5.5/server.xml
<!-- www.testsrv.local -->
<Host name="www.testsrv.local" appBase="/var/www/vhost1"
      unpackWARs="true" autoDeploy="true">
      <Context path="" docBase="htdocs" debug="0" reloadable="true"/>
      <Valve className="org.apache.catalina.valves.AccessLogValve"
             directory="/var/www/vhost1/logs"  prefix="tomcat_access_" suffix=".log"
             pattern="common" resolveHosts="false"/>
</Host>

At least you have to restart the Apache and the Tomcat:

# /etc/init.d/tomcat5.5 restart
# /etc/init.d/apache2 restart

[UPDATE]
There is a new version of this article available Tomcat 6 with Lenny and OpenBlueDragon on Tomcat 6.

, , , , , , , , , , ,

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.