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

Bereits im März hat New Atlanta eine OpenSource Version von BlueDragon angekündigt. Nun wurde sie unter OpenBlueDragon veröffentlicht. Da sich BlueDragon durchaus mit dem Coldfusion Server von Adobe messen kann, ist OpenBlueDragon ideal um Coldfusion in eine Linux/MySQL Umgebung zu integrieren und so eine direkte Konkurrenz zu der sonst üblichen PHP/MySQL Umgebungen werden.
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.

Nach dieser Anleitung soll OpenBlueDragon mit Tomcat 5.5 unter Debian Etch installiert werden. Anschließend soll Tomcat mit mod_jk mit dem Apache2 verbunden werden.
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.

Natürlich kann diese Anleitung auch verwendet werden, um nur den Tomcat zusammen mit Apache einzurichten. In diesem Fall müssen nur die OpenBlueDragon Abschnitte ausgelassen werden.
You can use this howto without the OpenBlueDragon parts to install an Tomcat server together with Apache2.

Es gibt verschiedene Gründe warum man Tomcat zusammen mit Apache einsetzt. Der Apache kann langsame Verbindugen Buffern, man kann mit weitere Funktionen benutzen wie PHP oder Perl, Apache Module stehen zur Verfügung wie mod_rewrite außerdem können die Virtuellen Hosts so konfiguriert werden, dass sie eigene Tomcat Instanzen benutzen.
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.

Für die Installation von Tomcat wird jedoch zuerst noch das Sun Java JDK gebraucht. Um diese zu installieren mussen in der /etc/apt/sources.list die “non-free” Pakete hinzugefügt werden:
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

Anschließend kann mit
Now you can install the Sun Java JDK:

# aptitude update
# aptitude install sun-java5-jdk

das Sun Java JDK installiert werden.

Nun kann Apache Tomcat installiert werden:
After that you can install the Tomcat server:

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

Um zu überprüfen ob Tomcat läuft, kann man folgende URL im Browser aufrufen: http://SERVER:8180
You can test the installation with this URL: http://SERVER:8180

Als nächstes muss ein Benutzer konfiguriert werden, mit dem Tomcat verwaltet werden soll.
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

Natürlich sollte das Passwort durch ein eigenes ersetzt werden ! Das deaktivieren von TOMCAT5_SECURITY ist notwendig um Zugriff auf die Administration zu erhalten. Sollte man die Administration nicht benötigen kann diesen Schritt natürlich weglassen oder nach dem festlegen der Einstellungen wieder aktivieren.
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.

Nun kann man sich in den Tomcat Manager einloggen http://SERVER:8180/manager/html sowie in den Administrator http://SERVER:8180/admin
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

Dort kann im Abschnitt “Deploy” das openbluedragon.war Paket hochgeladen werden.
You will find a deploy section in the manager. There you can upload and deploy the openbluedragon.war file.

Nach dem Neustart von Tomcat “/etc/init.d/tomcat5.5 restart” findet man openbluedragon in der Applications List im Tomcat Manager.
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 Apache2 mit Tomcat-Connector
Installation of the Apache2 Tomcat connector:

Tomcat besitzt zwar einen eingebauten Webserver, jedoch ist der Apache2 Webserver wesentlich Leistungsfähiger.

Installation:

# 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

Nun soll ein neuer VirtualHost angelegt werden. Dieser muss im Apache und im Tomcat angelegt werden.
Creating a new VirtualHost: (In Apache AND Tomcat)

Verzeichnise vorbereiten:
Prepare directories:

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

WEB-INF kopieren:
Copy WEB-INF:

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

VirtualHost im Apache anlegen:
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

Bemerkung: Man könnte auch alle Dateien an den Tomcat weiterleiten “JkMount /*” oder alle Dateien innerhalb eines Verzeichnisses “JkMount /folder/*“.
Note: You can forward all files “JkMount /*” or all files in a folder “JkMount /folder/*” to the Tomcat, too.

Host im Tomcat anlegen:
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>

Zum Schluss muss man den Tomcat sowie den Apache Server neu starten:
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.
Von diesen Artikel ist eine neue Version Verfügbar Tomcat 6 mit Lenny und OpenBlueDragon auf Tomcat 6

Schreibe einen Kommentar

eMail-Benachrichtigung bei weiteren Kommentaren.
Auch möglich: Abo ohne Kommentar.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.