Apache2 et Tomcat6 via jk_mod
Salut à tous.
Je viens de mettre en place un serveur pour nos "applications web".
Ce dernier utilisant Apache2 ainsi que Tomcat6 (Pour les applications basées Java).
J'ai réussi à mettre en place une configuration qui semble fonctionner "Pas trop mal".
Cependant, et étant la première fois que je réalise ce type d'installation, j'aimerai votre avis
sur la façon dont a été réalisée la mise en place. Ceci afin de savoir si certaine chose sont totalement déconseillées 8)
J'ai donc installé apache2 ainsi que tomcat6.
Afin d'obtenir une arborescence tomcat "simplifiée" j'ai créer un dossier /opt/tomcat6.
Dans cette dernière j'ai créé différent lien ainsi que des dossiers pour mes différentes
futur Vhost.
Code:
1 2 3 4 5 6 7
| lrwxrwxrwx 1 root root 23 Aug 19 13:14 bin -> /usr/share/tomcat6/bin/
lrwxrwxrwx 1 root root 13 Aug 19 13:14 conf -> /etc/tomcat6/
drwxr-xr-x 3 root root 4.0K Aug 20 11:16 Vhost1
lrwxrwxrwx 1 root root 23 Aug 19 13:14 lib -> /usr/share/tomcat6/lib/
lrwxrwxrwx 1 root root 17 Aug 19 13:15 logs -> /var/log/tomcat6/
drwxr-xr-x 3 root root 4.0K Aug 20 09:01 Vhost2
lrwxrwxrwx 1 root root 25 Aug 19 13:14 webapps -> /var/lib/tomcat6/webapps/ |
J'ai ensuite configurer mon fichier /etc/libapache2-mod-jk/workers.properties. Ceci afin de déclarer mes Workers (Un pour chaque application). Ici j'ai un doute, est-il possible de ne déclarer qu'un Worker? De ma vision nom. Une application = un port d'utilisation.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| workers.tomcat_home=/usr/share/tomcat6
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=Vhost1, Vhost2
worker.Vhost1.port=8009
worker.Vhost1.host=localhost
worker.Vhost1.type=ajp13
worker.Vhost1.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=Vhost1
worker.Vhost2.port=8010
worker.Vhost2.host=localhost
worker.Vhost2.type=ajp13
worker.Vhost2.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=Vhost2 |
Une fois le fichier Worker complet, j'ai modifier le fichier /opt/tomcat6/conf/server.xml. Ceci afin de configurer mes deux Vhosts ainsi que mes "Connector".
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>
<Host name="Vhost1" appBase="/opt/tomcat6/Vhost1" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Alias>Vhost1</Alias>
</Host>
<Host name="Vhost2" appBase="/opt/tomcat6/Vhost2" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Alias>Vhost2</Alias>
</Host> |
J'ai ensuite décompresser mes deux fichiers WAR dans un dossier root: Vhost1/ROOT et Vhost2/ROOT.
J'ai réalisé, du côté de apache2, la création d'un fichier pour chaque Vhost. J'ai ajouté pour chacun la ligne
Code:
JkMount /* WorkerConfiguré
J'ai loader les deux nouveaux fichier de Vhost du côté de apache2. (Le module lui était déjà loader).
J'ai finalement redémarrer les services (Apache2 et Tomca6).
Les sites précédemment configuré sous Apache2 fonctionne toujours très bien. Les deux applications sous Tomcat6 sont démarrée et fonctionnel. Dans l'ensemble la procédure semble fonctionnel. Cependant au vue des nombreux petits tutoriaux trouvé sur internet, aillant chacune leur "Méthode", je me pose la question de savoir si mon installation est "Correcte".
En espérant que vous pourrez me fournir des conseilles supplémentaires.
Meilleures Salutations,
ZerosCool