Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
elearning:workbooks:tomcat:tc04 [2023/10/04 14:19] adminelearning:workbooks:tomcat:tc04 [2023/10/04 14:53] (Version actuelle) – old revision restored (2023/04/11 05:56) admin
Ligne 74: Ligne 74:
   * arrêter une application,   * arrêter une application,
   * supprimer un application.   * supprimer un application.
- 
-Afin d'utiliser le Manager à partir d'un poste autre que celui du serveur lui-même, il est necéssaire d'éditer le fichier **$CATALINA_HOME/webapps/manager/META-INF/context.xml** en commentant la **Valve** : 
- 
-<code> 
-[root@centos8 work]# vi $CATALINA_HOME/webapps/manager/META-INF/context.xml 
-[root@centos8 work]# cat $CATALINA_HOME/webapps/manager/META-INF/context.xml 
-<?xml version="1.0" encoding="UTF-8"?> 
-<!-- 
-  Licensed to the Apache Software Foundation (ASF) under one or more 
-  contributor license agreements.  See the NOTICE file distributed with 
-  this work for additional information regarding copyright ownership. 
-  The ASF licenses this file to You under the Apache License, Version 2.0 
-  (the "License"); you may not use this file except in compliance with 
-  the License.  You may obtain a copy of the License at 
- 
-      http://www.apache.org/licenses/LICENSE-2.0 
- 
-  Unless required by applicable law or agreed to in writing, software 
-  distributed under the License is distributed on an "AS IS" BASIS, 
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-  See the License for the specific language governing permissions and 
-  limitations under the License. 
---> 
-<Context antiResourceLocking="false" privileged="true" > 
-  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor" 
-                   sameSiteCookies="strict" /> 
-  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" 
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> 
-  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/> 
-</Context> 
-</code> 
- 
-<WRAP center round important 60%> 
-**Important** : Notez que cette modification ne necéssite **pas** le redémarrage du serveur Tomcat. 
-</WRAP> 
  
 ====L'interface Texte==== ====L'interface Texte====
Ligne 142: Ligne 107:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth=admin:fenestros http://www.ittraining.loc:8080/manager/text/list +[root@centos7 bin]# lynx --dump -auth=admin:fenestros http://www.i2tch.loc:8080/manager/text/list 
-OK - Listed applications for virtual host [localhost]+OK - Listed applications for virtual host localhost
 /:running:0:ROOT /:running:0:ROOT
 /examples:running:0:examples /examples:running:0:examples
Ligne 149: Ligne 114:
 /manager:running:0:manager /manager:running:0:manager
 /docs:running:0:docs /docs:running:0:docs
 +
 </code> </code>
  
Ligne 160: Ligne 126:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/deploy?path=/sample&war=file:/usr/tomcat10/webapps/docs/appdev/sample/sample.war&update=true" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/deploy?path=/sample&war=file:/usr/tomcat8/webapps/docs/appdev/sample/sample.war&update=true" 
-OK - Deployed application at context path [/sample]+OK - Deployed application at context path /sample 
 </code> </code>
  
-<WRAP center round important 60%>+<WRAP center round important>
 **Important** : Notez l'utilisation de **&update=true**. Cette option spécifie à la commande deploy que si l'application existe déjà dans le serveur le manager doit d'abord la supprimer pour ensuite l'installer de nouveau. **Important** : Notez l'utilisation de **&update=true**. Cette option spécifie à la commande deploy que si l'application existe déjà dans le serveur le manager doit d'abord la supprimer pour ensuite l'installer de nouveau.
 </WRAP> </WRAP>
Ligne 171: Ligne 138:
  
 <code> <code>
-[root@centos8 work]# ls ../webapps/+[root@centos7 bin]# ls ../webapps/
 docs  examples  host-manager  manager  ROOT  sample  sample.war docs  examples  host-manager  manager  ROOT  sample  sample.war
 </code> </code>
Ligne 180: Ligne 147:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/start?path=/sample" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/start?path=/sample" 
-OK - Started application at context path [/sample]+OK - Started application at context path /sample
 </code> </code>
  
Ligne 189: Ligne 156:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/stop?path=/sample" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/stop?path=/sample" 
-OK - Stopped application at context path [/sample]+OK - Stopped application at context path /sample
 </code> </code>
  
Ligne 198: Ligne 165:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/start?path=/sample" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/start?path=/sample" 
-OK - Started application at context path [/sample] +OK - Started application at context path /sample 
- +[root@centos7 bin]# 
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/reload?path=/sample" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/reload?path=/sample" 
-OK - Reloaded application at context path [/sample]+OK - Reloaded application at context path /sample
 </code> </code>
  
Ligne 210: Ligne 177:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/undeploy?path=/sample" +[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/undeploy?path=/sample" 
-OK - Undeployed application at context path [/sample]+OK - Undeployed application at context path /sample
 </code> </code>
  
Ligne 217: Ligne 184:
  
 <code> <code>
-[root@centos8 work]# ls ../webapps/+[root@centos7 bin]# ls ../webapps/
 docs  examples  host-manager  manager  ROOT docs  examples  host-manager  manager  ROOT
 </code> </code>
Ligne 226: Ligne 193:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/resources"OK - Listed global resources of all types+[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/resources" 
 +OK - Listed global resources of all types
 UserDatabase:org.apache.catalina.users.MemoryUserDatabase UserDatabase:org.apache.catalina.users.MemoryUserDatabase
 </code> </code>
Ligne 241: Ligne 209:
  
 <code> <code>
-[root@centos8 work]# lynx --dump -auth admin:fenestros "http://www.ittraining.loc:8080/manager/text/serverinfo"+[root@centos7 bin]# lynx --dump -auth admin:fenestros "http://www.i2tch.loc:8080/manager/text/serverinfo"
 OK - Server info OK - Server info
-Tomcat Version: [Apache Tomcat/10.0.27] +Tomcat Version: Apache Tomcat/8.0.36 
-OS Name: [Linux] +OS Name: Linux 
-OS Version: [4.18.0-305.7.1.el8_4.x86_64] +OS Version: 3.10.0-1062.4.1.el7.x86_64 
-OS Architecture: [amd64] +OS Architecture: amd64 
-JVM Version: [1.8.0_312-b07] +JVM Version: 1.8.0_232-b09 
-JVM Vendor: [Red Hat, Inc.]+JVM Vendor: Oracle Corporation
 </code> </code>
  
Ligne 255: Ligne 223:
 Afin de pouvoir utiliser l'application manager en mode html, modifiez le fichier **$CATALINA_HOME/conf/tomcat-users.xml** ainsi : Afin de pouvoir utiliser l'application manager en mode html, modifiez le fichier **$CATALINA_HOME/conf/tomcat-users.xml** ainsi :
  
-<code> +<file>
-[root@centos8 work]# vi $CATALINA_HOME/conf/tomcat-users.xml +
-[root@centos8 work]# cat $CATALINA_HOME/conf/tomcat-users.xml+
 <?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
 <tomcat-users xmlns="http://tomcat.apache.org/xml" <tomcat-users xmlns="http://tomcat.apache.org/xml"
Ligne 271: Ligne 237:
   <user username="admin" password="fenestros" roles="manager-gui"/>   <user username="admin" password="fenestros" roles="manager-gui"/>
 </tomcat-users> </tomcat-users>
-</code>+</file>
  
-Re-démarrez le serveur Tomcat :+Arrêtez puis démarrez le serveur Tomcat :
  
 <code> <code>
-[root@centos8 work]# systemctl restart tomcat +[root@centos7 bin]# ./shutdown.sh 
-[root@centos8 work]# systemctl status tomcat +Using CATALINA_BASE  /usr/tomcat8 
-● tomcat.service - Apache Tomcat Web Application Container +Using CATALINA_HOME:   /usr/tomcat8 
-   Loadedloaded (/etc/systemd/system/tomcat.service; disabled; vendor presetdisabled) +Using CATALINA_TMPDIR/usr/tomcat8/temp 
-   Activeactive (running) since Wed 2023-10-04 10:09:53 EDT; 6s ago +Using JRE_HOME       /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64 
-  Process75805 ExecStop=/bin/kill -15 $MAINPID (code=exited, status=0/SUCCESS) +Using CLASSPATH      /usr/tomcat8/bin/bootstrap.jar:/usr/tomcat8/bin/tomcat-juli.jar 
-  Process75813 ExecStart=/usr/tomcat10/bin/startup.sh (code=exited, status=0/SUCCESS) +[root@centos7 bin]# ./startup.sh 
- Main PID75825 (java) +Using CATALINA_BASE  /usr/tomcat8 
-    Tasks50 (limit: 100949) +Using CATALINA_HOME:   /usr/tomcat8 
-   Memory: 327.6M +Using CATALINA_TMPDIR: /usr/tomcat8/temp 
-   CGroup: /system.slice/tomcat.service +Using JRE_HOME:        /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64 
-           └─75825 /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin/java -Djava.util.logging.c>+Using CLASSPATH:       /usr/tomcat8/bin/bootstrap.jar:/usr/tomcat8/bin/tomcat-juli.jar 
 +Tomcat started. 
 +</code>
  
-Oct 04 10:09:53 centos8.ittraining.loc systemd[1]: Starting Apache Tomcat Web Application Container..+Si vous vous êtes connecté à votre machine virtuelle via ssh, passez la VM CentOS 7 en démarrage en mode graphique : 
-Oct 04 10:09:53 centos8.ittraining.loc startup.sh[75813]: Existing PID file found during start+ 
-Oct 04 10:09:53 centos8.ittraining.loc startup.sh[75813]: Removing/clearing stale PID file. +<code> 
-Oct 04 10:09:53 centos8.ittraining.loc startup.sh[75813]: Tomcat started+[root@centos7 bin]# ls -l /etc/systemd/system/default.target 
-Oct 04 10:09:53 centos8.ittraining.loc systemd[1]: Started Apache Tomcat Web Application Container.+lrwxrwxrwx1 root root 37 Apr 30  2016 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target 
 +[root@centos7 bin]# rm -rf /etc/systemd/system/default.target 
 +[root@centos7 bin]# ln -s /lib/systemd/system/graphical.target /etc/systemd/system/default.target 
 +[root@centos7 bin]# ls -l /etc/systemd/system/default.target 
 +lrwxrwxrwx. 1 root root 36 Oct 29 13:27 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target 
 +[root@centos7 bin]# shutdown -h now
 </code> </code>
  
-Connectez-vous à votre machine virtuelle **Gateway** en mode graphique. Lancez ensuite le navigateur web Firefox dans la fenêtre de la VM et saisissez l'url http://10.0.2.45:8080/manager/html+Une fois la VM arrêtée, augmentez la mémoire qui lui est allouée à au moins 2Go (plus si votre machine hôte le permet), puis démarrez votre VM.
  
-Dans la boîte d'authentification renseignez l'utilisateur **admin** et le mot de passe **fenestros** :+Connectez-vous à votre machine virtuelle et **démarrez** Tomcat via ssh et démarrez Tomcat :
  
-{{ :elearning:workbooks:tomcat:capture_d_ecran_du_2023-10-04_16-14-03.png?600 |}}+<code> 
 +[root@centos7 bin]# ./startup.sh 
 +Using CATALINA_BASE  /usr/tomcat8 
 +Using CATALINA_HOME  /usr/tomcat8 
 +Using CATALINA_TMPDIR/usr/tomcat8/temp 
 +Using JRE_HOME       /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64 
 +Using CLASSPATH:       /usr/tomcat8/bin/bootstrap.jar:/usr/tomcat8/bin/tomcat-juli.jar 
 +Tomcat started. 
 +</code>
  
-Vous obtiendrez l'interface web de gestion de Tomcat :+Lancez ensuite le navigateur web Firefox dans la fenêtre de la VM et saisissez l'url http://www.i2tch.loc:8080/manager/html. 
  
-{{ :elearning:workbooks:tomcat:capture_d_ecran_du_2023-10-04_16-14-34.png?600 |}}+Dans la boîte d'authentification renseignez l'utilisateur **admin** et le mot de passe **fenestros**.
  
-<WRAP center round todo 60%> +ValidezVous obtiendrez l'interface web de gestion de Tomcat.
-**A faire** : Explorez cette interfaceEnsuite passez en revue chacun des exemples dans les applications **jsp-examples** et **servlets-examples** en affichant le résultat ainsi que le code. +
-</WRAP>+
  
 +Explorez cette interface. Ensuite passez en revue chacun des exemples dans les applications **jsp-examples** et **servlets-examples** en affichant le résultat ainsi que le code.
  
 ====L'interface ANT==== ====L'interface ANT====
Ligne 388: Ligne 368:
 <?xml version="1.0" encoding="ISO-8859-1" ?> <?xml version="1.0" encoding="ISO-8859-1" ?>
 <project name="Tomcat" default="deployer" basedir="."> <project name="Tomcat" default="deployer" basedir=".">
-<property name="manager.url" value="http://www.ittraining.loc:8080/manager/text" />+<property name="manager.url" value="http://www.i2tch.loc:8080/manager/text" />
 <property name="manager.user" value="admin" /> <property name="manager.user" value="admin" />
 <property name="manager.password" value="fenestros" /> <property name="manager.password" value="fenestros" />
Menu