Tomcat 5 Java 1.5 Mandriva mod_jk 1.2

Questions sur les problèmes d'intégration de Tomcat avec Apache (mod_jk, mod_jk2...).

Modérateur: Modérateurs

Messagede newbie le Jeu 21 Juil 2005, 0:31

Ce post fais suite (et déplace un e partie du post) à ce post
<a href='http://www.apachefrance.com/Forums/index.php?act=ST&f=3&t=3536&st=0#entry18886' target='_blank'>http://www.apachefrance.com/Forums/index.p...st=0#entry18886</a>


<span style='font-size:21pt;line-height:100%'><span style='color:blue'>1° Installlation de mod-jk</span></span>

<span style='font-size:12pt;line-height:100%'>mod_jk - connector et dialogues Tomcat <> Apache Webserver</span>
D'abord à Savoir ... ?JK is a project covering web-servers to Tomcat connectors, whereas mod_jk is the Apache module developed in JK. ?

<span style='font-size:13pt;line-height:100%'>Choix/Installation du jpackage pour jk_mod</span>
<a href='http://www.jpackage.org/rpm.php?id=2456' target='_blank'>http://www.jpackage.org/rpm.php?id=2456</a>
<a href='http://www.jpackage.org/rpm.php?id=2457' target='_blank'>http://www.jpackage.org/rpm.php?id=2457</a>

[root@mandrake etc]# urpmi --test <a href='http://mirrors.dotsrc.org/jpackage/1.6/redhat-el-3.0/free/RPMS/mod_jk-ap20-1.2.10-1jpp.i386.rpm' target='_blank'>http://mirrors.dotsrc.org/jpackage/1.6/red...0-1jpp.i386.rpm</a>
installation de mod_jk-ap20-1.2.10-1jpp.i386.rpm depuis /var/cache/urpmi/partial
Préparation ... #############################################
L'installation est possible
[root@mandrake etc]# urpmi -v <a href='http://mirrors.dotsrc.org/jpackage/1.6/redhat-el-3.0/free/RPMS/mod_jk-ap20-1.2.10-1jpp.i386.rpm' target='_blank'>http://mirrors.dotsrc.org/jpackage/1.6/red...0-1jpp.i386.rpm</a>
récupération des fichiers rpm [http://mirrors.dotsrc.org/jpackage/1.6/redhat-el-3.0/free/RPMS/mod_jk-ap20-1.2.10-1jpp.i386.rpm]...
... récupération effectuée
installation de mod_jk-ap20-1.2.10-1jpp.i386.rpm depuis /var/cache/urpmi/partial
starting installing packages
Transaction créée pour l'installation sur / (remove=0, install=0, upgrade=1)
ajout du paquetage mod_jk-ap20-1.2.10-1jpp.i386 (id=17730, eid=17730, update=1, file=/var/cache/urpmi/partial/mod_jk-ap20-1.2.10-1jpp.i386.rpm)
Préparation ... #############################################
1/1: mod_jk-ap20 #############################################
#############################################
Infos ::::
#############################################
Nom : mod_jk-ap20
Version : 1.2.10-1jpp
Architecture: i386
Taille : 251 Ko
Intitulé : Tomcat mod_jk connector for Apache 2.0.x.
Description : Tomcat mod_jk connector for Apache 2.0.x.
Fichiers :
?/usr/lib/httpd/modules/jk_jnicb.so
?/usr/lib/httpd/modules/mod_jk.so
?/usr/share/doc/mod_jk-ap20-1.2.10
?/usr/share/doc/mod_jk-ap20-1.2.10/CHANGES.txt
?/usr/share/doc/mod_jk-ap20-1.2.10/LICENSE
?/usr/share/doc/mod_jk-ap20-1.2.10/README
?/usr/share/doc/mod_jk-ap20-1.2.10/mod_jk.conf.sample
?/usr/share/doc/mod_jk-ap20-1.2.10/workers.properties.sample
Changelog :
* mar avr 19 2005 Jason Corley <jason.corley@gmail.com> - 0:1.2.10-1jpp - - 1.2.10

<span style='font-size:13pt;line-height:100%'>Install et paramétrage entre Tomcat et Apache avec Vhost</span>
Sources d'infos pour le JK v1.x ClassApacheConfig <a href='http://jakarta.apache.org/tomcat/tomcat-5.5-doc/catalina/docs/api/org/apache/jk/config/ApacheConfig.html' target='_blank'>http://jakarta.apache.org/tomcat/tomcat-5....acheConfig.html</a>
Exemple <a href='http://forum.plesk.com/showthread.php?threadid=3300&highlight=tomcat' target='_blank'>http://forum.plesk.com/showthread.php?thre...ighlight=tomcat</a>
Autre soluce <a href='http://www.apachefrance.com/Forums/index.php?showtopic=751' target='_blank'>http://www.apachefrance.com/Forums/index.php?showtopic=751</a>
Source d'inspiration mais JK2 (anciens connecteurs)
<a href='http://wiki.apache.org/jakarta-tomcat/Tomcat/Jk2Connector?highlight=%28apache%29%7C%28vhost%29' target='_blank'>http://wiki.apache.org/jakarta-tomcat/Tomc...9%7C%28vhost%29</a>
<a href='http://wiki.apache.org/jakarta-tomcat/TomcatWeb/Jk2Generic?highlight=%28apache%29%7C%28vhost%29' target='_blank'>http://wiki.apache.org/jakarta-tomcat/Tomc...9%7C%28vhost%29</a>
Pour un "build" du connector mo_jk <a href='http://blog.gilluminate.com/index.php?b=20050707161916&rss' target='_blank'>http://blog.gilluminate.com/index.php?b=20050707161916&rss</a>

Répertoires et Paramètres d'environnement
${tomcat_home} is the root directory of tomcat. Your Tomcat installation should have the following subdirectories:
${tomcat_home}\conf - Where you can place various configuration files
${tomcat_home}\webapps - Containing example applications
${tomcat_home}\bin - Where you place web server plugins
conf /etc/tomcat5
server /var/lib/tomcat5/server
temp /var/cache/tomcat5/temp
work /var/cache/tomcat5/work
common /var/lib/tomcat5/common
log /var/log/tomcat5
webapps /var/lib/tomcat5/webapps

A noter que JAVA_HOME est déja spécifié dans tomcat5.conf

#################################
<span style='color:red'>Retiré ... le temps de faire le ménage .. et de rendre cohérent le post</span>
#################################
##################################################################
Autres solutions . A la place du mod_jk-ap20-1.2.10-1jpp.i386.rpm
##################################################################
<a href='http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg155025.html' target='_blank'>http://www.mail-archive.com/tomcat-user@ja.../msg155025.html</a>
avec <a href='http://www.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/linux/jk-1.2.10/' target='_blank'>http://www.apache.org/dist/jakarta/tomcat-...inux/jk-1.2.10/</a>
ou <a href='http://mir2.ovh.net/ftp.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/linux/jk-1.2.10/' target='_blank'>http://mir2.ovh.net/ftp.apache.org/dist/ja...inux/jk-1.2.10/</a>
Avatar de l’utilisateur
newbie
Membre
Membre
 
Messages: 19
Inscription: Ven 01 Oct 2004, 20:53

Messagede newbie le Jeu 21 Juil 2005, 0:32

<span style='font-size:14pt;line-height:100%'><span style='color:red'>OK Cela marche .. Presque</span></span>

<span style='color:red'>Infos retirées le temps de mettre le post au clair sur les 3 dernièrs</span>

Comment vérifer que Apache supporte les worker Tomcat
la c'est par Tomcat/Catalina
<a href='http://192.168.xx.yy:8080/admin/frameset.jsp' target='_blank'>http://192.168.xx.yy:8080/admin/frameset.jsp</a>
La c'est par Apache
<a href='http://192.168.xx.yy:80/admin/frameset.jsp' target='_blank'>http://192.168.xx.yy:80/admin/frameset.jsp</a>
<a href='http://192.168.xx.yy/admin/frameset.jsp' target='_blank'>http://192.168.xx.yy/admin/frameset.jsp</a>

EN Fait il est déconseillé de tester avec /admin ou /maanger qui sont des applis spéciales nécessitant des configurations spécifiques .. donc tester avec :
/jsp-examples
/tomcat-docs
Avatar de l’utilisateur
newbie
Membre
Membre
 
Messages: 19
Inscription: Ven 01 Oct 2004, 20:53

Messagede newbie le Jeu 21 Juil 2005, 0:33

<span style='font-size:21pt;line-height:100%'><span style='color:green'>2° Configuration grossière ... </span></span>
Pour commencer ...

bon je referai le ménage dans les deux derniers posts qui sont confus .. tatonnements .. et désolé d'un post si long mais les exemples concrets sont utiles
Voila le résultat obtenu et comment

Pour les fichiers de configurations ...

1° Vous devez avoir <span style='color:blue'>/etc/httpd/conf/httpd.conf</span>
# Bring in additional module-specific configuration
#
Include modules.d/*.conf
Include /usr/share/tomcat5/conf/auto/mod_jk.conf
-----------------------------------------------------------------
Car c'est là que Tomcat génère ce fichier .. on peut toujours avec un paramètre le mettre un autre endroit, mais pourquoi compliquer ..

2° Avoir ce fichier ici <span style='color:blue'>/usr/share/tomcat5/conf/jk/workers.properties </span>
c'est là que le mod_jk.cong généré le cherche .. .. on peut toujours avec un paramètre le mettre un autre endroit, mais pourquoi compliquer ..

3° <span style='color:blue'>/usr/share/tomcat5/conf/server.xml</span>
VOIR le fichier donné comm exemple ci-après..
<span style='color:purple'>L'idée est d'avoir DEUX HOSTS :</span>
Host = localhost sur le port 8080 pour les taches admin et manager su
Donc pas de listener .. ici
Host = tombraind sur le port 80 par Apache
(tombraind pour moi ce peut etre http://www.toto.org ou http://www.toto.org/tomcat)
qui utilise la prise en charge par Apache
ICI un listener, donc un Connector avec Apache et un fichier mod-jk.conf généré.

Donc pour le meme Engine
1° Host localhost Tomcat sans connecteur apache
2° Host (ici tombraind) Tomcat avec connecteur Apache

Ce 2° Host est "include" par Apache (le include dans httpd.conf) et il trouve donc des Virtual Host paramétrés par Tomcat automatiquement.....
Donc, Quand on modifie l'administration/management ou on redémarre Tomcat, il regénère le fichier /usr/share/tomcat5/conf/auto/mod_jk.conf
Derrière Apache Httpd service, doit être redémarré pour prendre ne compte les infos de ce mod_jk.conf

- A SIGNALER les deux paramètres importants : forwardall = "true" ET noroot= "false" POUR que Tomcat gère les fichiers statiques comme les applis jsp

4° NE pas oublier <span style='color:blue'>/etc/hosts.conf</span>
127.0.0.1 localhost.locadomain localhost
192.168.xx.yy tombraind.domain.tld tombraind

<span style='color:red'>Problème restant ..</span>
Démarrage et Arrêt dans le bon ordre de Apache et Tomcat

<span style='font-size:14pt;line-height:100%'>Les fichiers pour exemple encore grossier mais marchent </span>

<span style='color:red'>/usr/share/tomcat5/conf/tomcat5.conf</span>
# tomcat4 service configuration file
# you could also override JAVA_HOME here
# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/java"
# You can pass some parameters to java
# here if you wish to
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
# Where your tomcat installation lives
# That change from previous RPM where TOMCAT_HOME
# used to be /var/tomcat.
# Now /var/tomcat will be the base for webapps only
CATALINA_HOME="/usr/share/tomcat5"
JASPER_HOME="/usr/share/tomcat5"
CATALINA_TMPDIR="/usr/share/tomcat5/temp"
JAVA_ENDORSED_DIRS="/usr/share/tomcat5/common/endorsed"
# What user should run tomcat
TOMCAT_USER="tomcat4"
# You can change your tomcat locale here
#LANG=en_US
# Time to wait in seconds, before killing process
SHUTDOWN_WAIT=30
# Set the TOMCAT_PID location
CATALINA_PID=/var/run/tomcat5.pid
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
# Just do not forget to export them :)

<span style='color:red'>/usr/share/tomcat5/conf/jk/workers.properties</span>
# workers.properties -
#
# This file provides jk derived plugins with the needed information to
# connect to the different tomcat workers. Note that the distributed
# version of this file requires modification before it is usable by a
# plugin.
#
# As a general note, the characters $( and ) are used internally to define
# macros. Do not use them in your own configuration!!!
#
# Whenever you see a set of lines such as:
# x=value
# y=$(x)\something
#
# the final value for y will be value\something
#
# Normaly all you will need to do is un-comment and modify the first three
# properties, i.e. workers.tomcat_home, workers.java_home and ps.
# Most of the configuration is derived from these.
#
# When you are done updating workers.tomcat_home, workers.java_home and ps
# you should have 5 workers configured:
#
# - An ajp12 worker that connects to localhost:8007
# - An ajp13 worker that connects to localhost:8009
# - An ajp13 worker that connects to localhost:8809
# - A jni inprocess worker.
# - A load balancer worker
#
# However by default the plugins will only use the ajp12 worker. To have
# the plugins use other workers you should modify the worker.list property.
#
#
# OPTIONS ( very important for jni mode )
#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/share/tomcat5
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/java
#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#
#------ DEFAULT worket list ------------------------------------------
#---------------------------------------------------------------------
# The workers that your plugins should create and work with
#
# Add 'inprocess' if you want JNI connector
worker.list=ajp12, ajp13, jboss
# , inprocess
#
#------ DEFAULT ajp12 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#
# Defining a worker named ajp12 and of type ajp12
# Note that the name and the type do not have to match.
#
worker.ajp12.port=8007
worker.ajp12.host=192.168.10.100
worker.ajp12.type=ajp12
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp12.lbfactor=1
#
#------ DEFAULT ajp13 WORKER DEFINITIONS -----------------------------
#---------------------------------------------------------------------
#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.port=8009
worker.ajp13.host=192.168.10.100
worker.ajp13.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp13.lbfactor=1
#
# Specify the size of the open connection cache.
#worker.ajp13.cachesize
#
# Defining a worker named jboss and of type ajp13
#
worker.jboss.port=8809
worker.jboss.host=192.168.10.100
worker.jboss.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.jboss.lbfactor=1
#
# Specify the size of the open connection cache.
#worker.jboss.cachesize
#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, ajp13, jboss
#
#------ DEFAULT JNI WORKER DEFINITION---------------------------------
#---------------------------------------------------------------------
#
# Defining a worker named inprocess and of type jni
# Note that the name and the type do not have to match.
#
worker.inprocess.type=jni
#
#------ CLASSPATH DEFINITION -----------------------------------------
#---------------------------------------------------------------------
#
# Additional class path components.
#
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
#
# Setting the command line for tomcat.
# Note: The cmd_line string may not contain spaces.
#
worker.inprocess.cmd_line=start
# Not needed, but can be customized.
#worker.inprocess.cmd_line=-config
#worker.inprocess.cmd_line=$(workers.tomcat_home)$(ps)conf$(ps)server.xml
#worker.inprocess.cmd_line=-home
#worker.inprocess.cmd_line=$(workers.tomcat_home)
#
# The JVM that we are about to use
#
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)server$(ps)libjvm.so
#
# Setting the place for the stdout and stderr of tomcat
#
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
#
# Setting the tomcat.home Java property
#
#worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)
#
# Java system properties
#
# worker.inprocess.sysprops=java.compiler=NONE
# worker.inprocess.sysprops=myprop=mypropvalue
#
# Additional path components.
#
# worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin
#

<span style='color:red'>/usr/share/tomcat5/server.xml</span>
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<span style='color:green'> <Listener className="org.apache.jk.config.ApacheConfig" modJk="/usr/lib/httpd/modules/mod_jk.so"/></span>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<span style='color:green'> <Host appBase="webapps" name="localhost">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
</Host>
<Host appBase="webapps" name="tombraind">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="tombraind_log." suffix=".txt" timestamp="true"/>
<Listener className="org.apache.jk.config.ApacheConfig" append="true" noRoot="false" forwardAll="true" modJk="/usr/lib/httpd/modules/mod_jk.so"/>
</Host></span>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.*,127.0.0.1 " deny=""/>
</Engine>
</Service>
</Server>

<span style='color:red'>/usr/share/tomcat5/conf/auto/mod_jk.conf</span>
########## Auto generated on Thu Jul 21 00:37:01 CEST 2005##########
<IfModule !mod_jk.c>
LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>

JkWorkersFile "/usr/share/tomcat5/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat5/logs/mod_jk.log"
JkLogLevel emerg

<VirtualHost tombraind>
ServerName tombraind
JkMount /struts-examples ajp13
JkMount /struts-examples/* ajp13
JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13
JkMount /webdav ajp13
JkMount /webdav/* ajp13
JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13
JkMount /balancer ajp13
JkMount /balancer/* ajp13
JkMount /struts-blank ajp13
JkMount /struts-blank/* ajp13
JkMount /struts-example ajp13
JkMount /struts-example/* ajp13
JkMount /struts-tiles-documentation ajp13
JkMount /struts-tiles-documentation/* ajp13
JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13
JkMount /struts-documentation ajp13
JkMount /struts-documentation/* ajp13
JkMount / ajp13
JkMount /* ajp13
DocumentRoot "/usr/share/tomcat5/webapps/ROOT"
</VirtualHost>
Avatar de l’utilisateur
newbie
Membre
Membre
 
Messages: 19
Inscription: Ven 01 Oct 2004, 20:53

Messagede newbie le Lun 25 Juil 2005, 12:34

<span style='font-size:21pt;line-height:100%'><span style='color:green'>3° Configuration multiples ... </span></span>
On va configurer avec :
- plusieurs virtual hosts avec les répertoires de base de Tomcat (Webapps, .)
- utliser <context path> pour accèder à de applis en dehors de TOMCAT_HOME
- permettre /admin et /manager pour les Virtual Hosts

<span style='color:green'>LEs SITEs que je conseille :</span>
<a href='http://www-igm.univ-mlv.fr/~dr/XPOSE2003/tomcat/tomcat.php?rub=5' target='_blank'>http://www-igm.univ-mlv.fr/~dr/XPOSE2003/t...omcat.php?rub=5</a>
<a href='http://jakarta.apache.org/tomcat/connectors-doc/index.html' target='_blank'>http://jakarta.apache.org/tomcat/connectors-doc/index.html</a>
pour voir les paramètres ... qui changent selon la version de Tomcat


<span style='font-size:14pt;line-height:100%'><span style='color:red'>A- nettoyage de workers.properties</span></span>
- enlever ajp12 inutile pour Tomcat5
- remettre "localhost" à la place de "192.168.10.100" qui est plus efficace, un IP est utile si Tomcat et Apache sont sur deux machines différentes

************* fichier modifié *****************
# workers.properties -
# OPTIONS ( very important for jni mode )

# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/share/tomcat5
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/java
#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#
#------ DEFAULT worket list ------------------------------------------
#---------------------------------------------------------------------
#
# The workers that your plugins should create and work with
#
# Add 'inprocess' if you want JNI connector
worker.list=ajp13, jboss
# ajp12, inprocess
#
#------ DEFAULT ajp12 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#
# Defining a worker named ajp12 and of type ajp12
# Note that the name and the type do not have to match.
#
# worker.ajp12.port=8007
# worker.ajp12.host=localhost
# worker.ajp12.type=ajp12
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
# worker.ajp12.lbfactor=1
#
#------ DEFAULT ajp13 WORKER DEFINITIONS -----------------------------
#---------------------------------------------------------------------
#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp13.lbfactor=5
#
# Specify the size of the open connection cache.
#worker.ajp13.cachesize
#
# Defining a worker named jboss and of type ajp13
#
worker.jboss.port=8809
worker.jboss.host=localhost
worker.jboss.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.jboss.lbfactor=1
#
# Specify the size of the open connection cache.
#worker.jboss.cachesize
#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp13, jboss
# ajp12,
#
#------ DEFAULT JNI WORKER DEFINITION---------------------------------
#---------------------------------------------------------------------
#
# Defining a worker named inprocess and of type jni
# Note that the name and the type do not have to match.
#
worker.inprocess.type=jni
#
#------ CLASSPATH DEFINITION -----------------------------------------
#---------------------------------------------------------------------
#
# Additional class path components.
#
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
#
# Setting the command line for tomcat.
# Note: The cmd_line string may not contain spaces.
#
worker.inprocess.cmd_line=start

# Not needed, but can be customized.
#worker.inprocess.cmd_line=-config
#worker.inprocess.cmd_line=$(workers.tomcat_home)$(ps)conf$(ps)server.xml
#worker.inprocess.cmd_line=-home
#worker.inprocess.cmd_line=$(workers.tomcat_home)
#
# The JVM that we are about to use
#
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)server$(ps)libjvm.so
#
# Setting the place for the stdout and stderr of tomcat
#
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
#
# Setting the tomcat.home Java property
#
#worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)
#
# Java system properties
#
# worker.inprocess.sysprops=java.compiler=NONE
# worker.inprocess.sysprops=myprop=mypropvalue
#
# Additional path components.
#
# worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin
#

<span style='font-size:14pt;line-height:100%'><span style='color:red'>B- server.xml</span></span>
Ce qui est important :::

A- "localhost" DOIT etre spécifier même si il y a d'autres Hosts
<span style='color:blue'> <Engine defaultHost="localhost" name="Catalina">
<Host name="localhost" appBase="webapps">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
</Host></span>

B- Deux Hosts complémentaires rajoutés
- "tombraind" sans Alias utilisable en réseau local
- "semantic" avec un alias accessible par Internet (ne pas oublier de mettre l'info dans le /Etc/hosts.conf)
<span style='color:orange'><Host name="semantic" appBase="webapps">
<Alias>semantic.xxxx.org</Alias></span>

C- le répertoire de Base = "webapps"
<Host name="semantic" appBase="webapps">
ce qui veut dire que les applis sont déployées dans le répertoire ../tomcat5/work/semantic et ../tombraind

D- Path supplémentaire /daisy ici
1- EST Obligatoire .. <Context path="" docBase="" reloadable="true" debug="0"/>
On peut mettre le docBase sur le chemin que l'on veut, c'est là ou est cherché la page affichée en arrivant sur ce Host
2- Ici, on ajoute une appli accessible par //semantic/daisy en local et //www.xxx.org/daisy
3- Le répertoire de base de l'application est ailleurs en l'occurence docBase="/usr/share/daisy/daisywiki/webapp"
4- le logger (logs) est spécifique pour ce Host et ce Contexte
<span style='color:purple'> <Context path="" docBase="" reloadable="true" debug="0"/>
<Context path="/daisy" docBase="/usr/share/daisy/daisywiki/webapp" reloadable="true" crossContext="true" override="true" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="semantic_daisy_log." suffix=".txt" timestamp="true"/>
</Context></span>

D- donner accès au applis /admin et /manager pour chaque Host
IL FAUT mettre ces infos pour chaque Host --- <Context path="/admin" docBase="/usr/share/tomcat5/server/webapps/admin" debug="0" privileged="true" />

E- donner/interdire accès aux Hosts
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.*,127.0.0.1 " deny=""/>
Ceci m'interdit tout accès par Internet
donc à enlever ou spécifier mieux et Ceci PAR Host si vous le voulez


************* server.xml modifié ***********************
<?xml version='1.0' encoding='utf-8'?>
<Server>
..<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
..<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
..<Listener className="org.apache.jk.config.ApacheConfig" modJk="/usr/lib/httpd/modules/mod_jk.so"/>
..<GlobalNamingResources>
....<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
....<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
....<ResourceParams name="UserDatabase">
......<parameter>
........<name>factory</name>
........<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
......</parameter>
......<parameter>
........<name>pathname</name>
........<value>conf/tomcat-users.xml</value>
......</parameter>
....</ResourceParams>
......</GlobalNamingResources>

<Service name="Catalina">
..<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
..</Connector>
..<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
..</Connector>

<span style='color:blue'>....<Engine defaultHost="localhost" name="Catalina">

......<Host name="localhost" appBase="webapps">
........<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
......</Host></span>

......<Host name="tombraind" appBase="webapps">
........<Logger className="org.apache.catalina.logger.FileLogger" prefix="tombraind_log." suffix=".txt" timestamp="true"/>
........<Listener className="org.apache.jk.config.ApacheConfig" append="true" noRoot="false" forwardAll="true" modJk="/usr/lib/httpd/modules/mod_jk.so"/>
......<Context path="" docBase="" reloadable="true" debug="0"/>
......<Context path="/manager" docBase="/usr/share/tomcat5/server/webapps/manager" debug="0" privileged="true">
........<Logger className="org.apache.catalina.logger.FileLogger" prefix="tombraind_manager_log." suffix=".txt" timestamp="true"/>
......</Context>
......<Context path="/admin" docBase="/usr/share/tomcat5/server/webapps/admin" debug="0" privileged="true" />
....</Host>

<span style='color:orange'>....<Host name="semantic" appBase="webapps">
......<Alias>semantic.xxxx.org</Alias></span>
......<Logger className="org.apache.catalina.logger.FileLogger" prefix="semantic_log." suffix=".txt" timestamp="true"/>
......<span style='color:purple'><Context path="" docBase="" reloadable="true" debug="0"/>
......<Context path="/daisy" docBase="/usr/share/daisy/daisywiki/webapp" reloadable="true" crossContext="true" override="true" debug="0">
........<Logger className="org.apache.catalina.logger.FileLogger" prefix="semantic_daisy_log." suffix=".txt" timestamp="true"/>
......</Context></span>
......<Context path="/manager" docBase="/usr/share/tomcat5/server/webapps/manager" debug="0" privileged="true">
........<Logger className="org.apache.catalina.logger.FileLogger" prefix="semantic_manager_log." suffix=".txt" timestamp="true"/>
......</Context>
......<Context path="/admin" docBase="/usr/share/tomcat5/server/webapps/admin" debug="0" privileged="true" />
........<Listener className="org.apache.jk.config.ApacheConfig" append="true" noRoot="false" forwardAll="true" modJk="/usr/lib/httpd/modules/mod_jk.so"/>
....</Host>

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.*,127.0.0.1 " deny=""/>
-->
....</Engine>
..</Service>
</Server>
************************************************************

<span style='font-size:14pt;line-height:100%'><span style='color:red'>B- mod_jk.conf généré par Tomcat5</span></span>
voilà le fichier obtenu ... après redémarrage de Tomcat5
Ne pas oublier aussi de rédémarrer Apache après pour qu'il intègre ces infos

########## Auto generated on Mon Jul 25 12:51:39 CEST 2005##########
<IfModule !mod_jk.c>
LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>
JkWorkersFile "/usr/share/tomcat5/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat5/logs/mod_jk.log"
JkLogLevel emerg

<VirtualHost semantic>
ServerName semantic
ServerAlias semantic.xxxx.com
JkMount /struts-examples ajp13
JkMount /struts-examples/* ajp13

JkMount /webdav ajp13
JkMount /webdav/* ajp13

JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13

JkMount /struts-documentation ajp13
JkMount /struts-documentation/* ajp13

JkMount /manager ajp13
JkMount /manager/* ajp13

JkMount /admin ajp13
JkMount /admin/* ajp13

JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13

JkMount /balancer ajp13
JkMount /balancer/* ajp13

JkMount /struts-blank ajp13
JkMount /struts-blank/* ajp13

JkMount /struts-tiles-documentation ajp13
JkMount /struts-tiles-documentation/* ajp13

JkMount /struts-example ajp13
JkMount /struts-example/* ajp13

JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13

JkMount /daisy ajp13
JkMount /daisy/* ajp13

JkMount / ajp13
JkMount /* ajp13
DocumentRoot "/usr/share/tomcat5/webapps"
</VirtualHost>

<VirtualHost tombraind>
ServerName tombraind

JkMount /struts-examples ajp13
JkMount /struts-examples/* ajp13

JkMount /webdav ajp13
JkMount /webdav/* ajp13

JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13

JkMount /struts-documentation ajp13
JkMount /struts-documentation/* ajp13

JkMount /manager ajp13
JkMount /manager/* ajp13

JkMount /admin ajp13
JkMount /admin/* ajp13

JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13

JkMount /balancer ajp13
JkMount /balancer/* ajp13

JkMount /struts-blank ajp13
JkMount /struts-blank/* ajp13

JkMount /struts-tiles-documentation ajp13
JkMount /struts-tiles-documentation/* ajp13

JkMount /struts-example ajp13
JkMount /struts-example/* ajp13

JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13

JkMount / ajp13
JkMount /* ajp13
DocumentRoot "/usr/share/tomcat5/webapps"
</VirtualHost>
Avatar de l’utilisateur
newbie
Membre
Membre
 
Messages: 19
Inscription: Ven 01 Oct 2004, 20:53

Messagede newbie le Ven 12 Aoû 2005, 18:56

<span style='color:red'><span style='font-size:14pt;line-height:100%'>Préséance du Virtual host par défaut </span></span>
j'ai cherché pdt deux heures alors que c'est évident ..

ICI, il est indiqué ... <a href='http://httpd.apache.org/docs/2.1/fr/vhosts/details.html' target='_blank'>http://httpd.apache.org/docs/2.1/fr/vhosts/details.html</a>
Pour tous les champs ServerName non définis, dans le cas d'une configuration en serveur virtuel par nom, la valeur adoptée par défaut est la première adresse donnée dans la section VirtualHost qui définit le serveur virtuel.
Si un serveur virtuel contient la valeur magique _default_, il fonctionne sur le même ServerName que le serveur principal.



J'utilise dans mom vhost.conf - la directive _default_
<--------------------vhost.conf------------------------->
<VirtualHost _default_:*>
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride None
Options +Indexes
Allow from all
</Directory>
</VirtualHost>
<--------------------vhost.conf------------------------->

<VirtualHost _default_:*>
fait en sorte que pour toutes adresses et port qui ne sont pas déclarés, la redirection se fasse sur le DocumentRott indiqué ici
Soit, sit je fais <a href='http://topo.site.com' target='_blank'>http://topo.site.com</a> qui est une erreur alors que j'ai prévu un <a href='http://cocoon.site.com' target='_blank'>http://cocoon.site.com</a> - je me retrouve dans ce cas de redirection
on peut avoir <VirtualHost _default_:80>

<span style='color:red'>Problème
Sur une adresse mal formée, quoique que je fasse ... je n'obtenais pas la redirection sur le _default_ et je tombais sur la page d'enteteTomcat</span>



<span style='color:green'>Solution - l'ordre entre les deux include dans httpd.conf</span>
En effet, tout simplement, J'avais le <span style='color:red'>mauvais 'ordre suivant :</span>
Include /usr/share/tomcat5/conf/auto/mod_jk.conf
Include conf/vhosts.d/*.conf

<span style='color:green'>Le bon ordre est le suivant dans httpd.conf:</span>
Include conf/vhosts.d/*.conf
Include /usr/share/tomcat5/conf/auto/mod_jk.conf

et tout simplement pour la raison suivante "la valeur adoptée (pour _default_) par défaut est la première adresse donnée dans la section VirtualHost qui définit le serveur virtuel."
Avatar de l’utilisateur
newbie
Membre
Membre
 
Messages: 19
Inscription: Ven 01 Oct 2004, 20:53


Retourner vers Intégration Apache

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités