Table des matières
Version : 2023.01.
Dernière mise-à-jour : 2023/10/09 09:53
SER502 - Installation de Tomcat et les serveurs associés
Contenu du Module
- SER502 - Installation de Tomcat et les serveurs associés
- Contenu du Module
- Désactiver SELinux
- Tomcat et JDK
- Apache
- Présentation d'Apache
- Installation
- Testez le serveur apache avec telnet
- Coupler Tomcat et Apache
- MariaDB
- Présentation
- Installation
- Configuration
- OpenLDAP
- Présentation
- Installation
Désactiver SELinux
Afin d'éviter à ce que SELinux interfère avec l'installation et la configuration de Tomcat 8, éditez le fichier /etc/selinux/config afin de le désactiver :
[trainee@centos8 ~]$ su - Password: fenestros [root@centos8 ~]# vi /etc/selinux/config [root@centos8 ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
Redémarrez ensuite le système :
[root@centos8 ~]# shutdown -r now
Reconfigurer les Dépôts de CentOS 8
Afin de reconfigurer les dépôts de CentOS 8, saisissez les deux commandes suivantes :
[root@centos8 ~]# sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* [root@centos8 ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Tomcat et JDK
Pour installer Tomcat 10 sous CentOS 8, il convient de saisir les commandes suivantes :
[trainee@centos8 ~]$ su - Password: fenestros [root@centos8 ~]# wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.27/bin/apache-tomcat-10.0.27.tar.gz --2023-10-03 03:32:49-- https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.27/bin/apache-tomcat-10.0.27.tar.gz Resolving archive.apache.org (archive.apache.org)... 65.108.204.189, 2a01:4f9:1a:a084::2 Connecting to archive.apache.org (archive.apache.org)|65.108.204.189|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 11984522 (11M) [application/x-gzip] Saving to: ‘apache-tomcat-10.0.27.tar.gz’ apache-tomcat-10.0.27 100%[=======================>] 11.43M 8.82MB/s in 1.3s 2023-10-03 03:32:51 (8.82 MB/s) - ‘apache-tomcat-10.0.27.tar.gz’ saved [11984522/11984522] FINISHED --2023-10-03 03:32:51-- Total wall clock time: 1.9s Downloaded: 1 files, 11M in 1.3s (8.82 MB/s)
Puis :
[root@centos8 ~]# tar xvf apache-tomcat-10.0.27.tar.gz ... [root@centos8 ~]# mv apache-tomcat-10.0.27 /usr/tomcat10
Installez maintenant le JDK :
[root@centos8 ~]# dnf install java Last metadata expiration check: 0:08:37 ago on Tue 03 Oct 2023 03:55:50 EDT. Package java-1.8.0-openjdk-1:1.8.0.292.b10-1.el8_4.x86_64 is already installed. Dependencies resolved. ====================================================================================== Package Arch Version Repository Size ====================================================================================== Upgrading: copy-jdk-configs noarch 4.0-2.el8 appstream 31 k java-1.8.0-openjdk x86_64 1:1.8.0.312.b07-2.el8_5 appstream 341 k java-1.8.0-openjdk-devel x86_64 1:1.8.0.312.b07-2.el8_5 appstream 9.8 M java-1.8.0-openjdk-headless x86_64 1:1.8.0.312.b07-2.el8_5 appstream 34 M Transaction Summary ====================================================================================== Upgrade 4 Packages Total download size: 44 M Is this ok [y/N]: y
Vérifiez la présence du jre-1.8.0-openjdk dans le répertoire /usr/lib/jvm :
[root@centos8 ~]# ls -l /usr/lib/jvm/jre-1.8.0-openjdk* lrwxrwxrwx. 1 root root 35 Jul 19 2021 /usr/lib/jvm/jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk lrwxrwxrwx 1 root root 51 Nov 13 2021 /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 -> java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre
Ajoutez les trois lignes suivantes au fichier /etc/profile :
... PATH=$PATH:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 export PATH JAVA_HOME
Important : Vérifiez que la version du jre-1.8.0-openjdk dans le fichier /etc/profile est la même que dans le répertoire /usr/lib/jvm.
Rechargez le fichier /etc/profile et vérifiez les valeurs des deux variables précédemment déclarées :
[root@centos8 ~]# source /etc/profile [root@centos8 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin [root@centos8 ~]# echo $JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64
Vérifiez ensuite la version de java :
[root@centos8 ~]# java -version openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-b07) OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
Définissez maintenant la variable CATALINA_HOME dans le fichier /etc/profile :
... # Tomcat CATALINA_HOME="/usr/tomcat10" export CATALINA_HOME PATH=$PATH:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 export PATH JAVA_HOME
Rechargez /etc/profile :
[root@centos8 ~]# source /etc/profile [root@centos8 ~]# echo $CATALINA_HOME /usr/tomcat10
Démarrez maintenant Tomcat 8 :
[root@centos8 ~]# cd /usr/tomcat10/bin [root@centos8 bin]# ./startup.sh Using CATALINA_BASE: /usr/tomcat10 Using CATALINA_HOME: /usr/tomcat10 Using CATALINA_TMPDIR: /usr/tomcat10/temp Using JRE_HOME: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 Using CLASSPATH: /usr/tomcat10/bin/bootstrap.jar:/usr/tomcat10/bin/tomcat-juli.jar Using CATALINA_OPTS: Tomcat started.
Utilisez le navigateur de texte lynx pour tester Tomcat 8 :
[root@centos8 bin]# yum install lynx ... [root@centos8 bin]# lynx --dump http://localhost:8080 [1]Home [2]Documentation [3]Configuration [4]Examples [5]Wiki [6]Mailing Lists [7]Find Help Apache Tomcat/10.0.27 If you're seeing this, you've successfully installed Tomcat. Congratulations! [tomcat logo] Recommended Reading: ...
Apache
Présentation d'Apache
Un serveur web est une machine doté d'un logiciel serveur qui attend des requêtes de la part de machines clientes afin de leur livrer de documents de types différents.
En 1994 le développement du serveur web le plus connue à l'époque, le démon HTTP, a été arrêté suite au départ de la NCSA de son principal développeur, Rob McCool.
Au début de l'année 1995, un groupe de webmestres indépendants s'est mis en place sous la direction de Brian Behlendorf et Cliff Skolnick pour reprendre le travail sur ce démon. Ce projet a pris le nom Apache. En même temps la NCSA a repris son propre travail de développement sur son démon HTTP. L'arrivée dans le groupe Apache de deux personnes de la NCSA en tant que membres honoraires, Brandon Long et Beth Frank a permis la mise en commun des connaissances des deux groupes.
Le projet Apache est un projet de développement d'un serveur web libre pour les plateformes Unix et Windows™. La première version officielle, la 0.6.2 est sortie en avril 1995.
La Fondation Apache, créée en 1999 par l'équipe Apache, gère aujourd'hui non seulement le projet Apache mais aussi un grand nombre d'autres projets. La liste des projets de la Fondation peut être trouvée ici.
Apache est modulaire. Certains modules fondamentaux conditionnent comment Apache traite la question du multitraitement. Les modules multitraitements - MPM - Multi-Processing Modules - sont différents selon le système d'exploitation utilisé et la charge attendue.
- mpm-winnt - module propre à Windows™ qui utilise son support réseau natif,
- prefork - module propre à Unix et Linux qui implémente un serveur mono-tâche à duplication,
- perchild - module propre à Unix et Linux qui implémente un serveur autorisant des démons servant les requêtes à être assigner à plusieurs id utilisateurs,
- worker - module propre à Unix et Linux qui implémente un serveur hybride multi-tâche et multitraitement.
Ces modules sont compilés statiquement au binaire Apache et sont mutuellement exclusifs.
Installation
Sous CentOS 8, Apache n'est pas installé par défaut :
[root@centos8 bin]# cd ~ [root@centos8 ~]# rpm -qa | grep httpd [root@centos8 ~]# dnf install httpd Last metadata expiration check: 0:54:32 ago on Tue 03 Oct 2023 07:16:01 EDT. Dependencies resolved. ====================================================================================== Package Arch Version Repository Size ====================================================================================== Installing: httpd x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 1.4 M Installing dependencies: apr x86_64 1.6.3-12.el8 appstream 129 k apr-util x86_64 1.6.1-6.el8 appstream 105 k centos-logos-httpd noarch 85.8-2.el8 baseos 75 k httpd-filesystem noarch 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 39 k httpd-tools x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 107 k mod_http2 x86_64 1.15.7-3.module_el8.4.0+778+c970deab appstream 154 k Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8 appstream 25 k apr-util-openssl x86_64 1.6.1-6.el8 appstream 27 k Enabling module streams: httpd 2.4 Transaction Summary ====================================================================================== Install 9 Packages Total download size: 2.1 M Installed size: 5.6 M Is this ok [y/N]: y
Le service n'est pas configuré pour démarrer automatiquement :
[root@centos7 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:httpd(8) man:apachectl(8)
Saisissez donc les commandes suivantes et vérifiez le résultat :
[root@centos8 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: di> Active: inactive (dead) Docs: man:httpd.service(8) [root@centos8 ~]# systemctl enable httpd Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service. [root@centos8 ~]# systemctl start httpd [root@centos8 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: dis> Active: active (running) since Tue 2023-10-03 08:11:58 EDT; 4s ago Docs: man:httpd.service(8) Main PID: 48517 (httpd) Status: "Started, listening on: port 80" Tasks: 213 (limit: 100949) Memory: 39.2M CGroup: /system.slice/httpd.service ├─48517 /usr/sbin/httpd -DFOREGROUND ├─48518 /usr/sbin/httpd -DFOREGROUND ├─48519 /usr/sbin/httpd -DFOREGROUND ├─48520 /usr/sbin/httpd -DFOREGROUND └─48521 /usr/sbin/httpd -DFOREGROUND Oct 03 08:11:58 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... Oct 03 08:11:58 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. Oct 03 08:11:58 centos8.ittraining.loc httpd[48517]: Server configured, listening on:>
Testez le serveur apache avec telnet
Telnet n'est pas installé par défaut sous CentOS 8 :
[root@centos8 ~]# which telnet /usr/bin/which: no telnet in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin)
Installez donc telnet :
[root@centos8 ~]# dnf install telnet Last metadata expiration check: 0:57:56 ago on Tue 03 Oct 2023 07:16:01 EDT. Dependencies resolved. ====================================================================================== Package Architecture Version Repository Size ====================================================================================== Installing: telnet x86_64 1:0.17-76.el8 appstream 72 k Transaction Summary ====================================================================================== Install 1 Package Total download size: 72 k Installed size: 119 k Is this ok [y/N]: y
Testez maintenant le service Apache :
[root@centos8 ~]# telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'.
Tapez ensuite GET / :
GET / ... <hr> <div class="row"> <div class="col"> <h2 class="alert-heading">Important note!</h2> <p>The CentOS Project has nothing to do with this website or its content, it just provides the software that makes the website run.</p> <p>If you have issues with the content of this site, contact the owner of the domain, not the CentOS project. Unless you intended to visit CentOS.org, the CentOS Project does not have anything to do with this website, the content or the lack of it.</p> <p>For example, if this website is www.example.com, you would find the owner of the example.com domain at the following WHOIS server: <a href="http://www.internic.net/whois.html">http://www.internic.net/whois.html</a></p> </div> </div> </main> <footer class="container"> <div>© 2021 The CentOS Project | <a href="https://www.centos.org/legal/">Legal</a> | <a href="https://www.centos.org/legal/privacy/">Privacy</a></div> </footer> </body> </html> Connection closed by foreign host. [root@centos8 ~]#
Pour voir la version d'Apache installée, utilisez la commande suivante :
[root@centos8 ~]# httpd -v Server version: Apache/2.4.37 (centos) Server built: Nov 12 2021 04:57:27
Coupler Tomcat et Apache
Le schéma suivant indique le couplage Tomcat/Apache :
Téléchargez le connecteur mod-jk pour Apache :
[root@centos8 ~]# wget http://apache.mirrors.ovh.net/ftp.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.49-src.tar.gz --2023-10-03 08:19:47-- http://apache.mirrors.ovh.net/ftp.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.49-src.tar.gz Resolving apache.mirrors.ovh.net (apache.mirrors.ovh.net)... 213.32.5.7 Connecting to apache.mirrors.ovh.net (apache.mirrors.ovh.net)|213.32.5.7|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1702479 (1.6M) [application/octet-stream] Saving to: ‘tomcat-connectors-1.2.49-src.tar.gz’ tomcat-connectors-1.2 100%[=======================>] 1.62M --.-KB/s in 0.07s 2023-10-03 08:19:47 (23.9 MB/s) - ‘tomcat-connectors-1.2.49-src.tar.gz’ saved [1702479/1702479]
Désarchivez l'archive et placez-vous dans le répertoire tomcat-connectors-1.2.49-src :
[root@centos8 ~]# tar xvf tomcat-connectors-1.2.49-src.tar.gz [root@centos8 ~]# cd tomcat-connectors-1.2.49-src/
Installez le binaire apxs inclut dans le paquet httpd-devel. Le binaire apxs est utilisé pour construire les modules d'Apache :
[root@centos8 tomcat-connectors-1.2.49-src]# dnf install httpd-devel Last metadata expiration check: 1:05:29 ago on Tue 03 Oct 2023 07:16:01 EDT. Dependencies resolved. ====================================================================================== Package Arch Version Repository Size ====================================================================================== Installing: httpd-devel x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 222 k Upgrading: libdb x86_64 5.3.28-42.el8_4 baseos 751 k libdb-utils x86_64 5.3.28-42.el8_4 baseos 150 k openldap x86_64 2.4.46-18.el8 baseos 352 k Installing dependencies: apr-devel x86_64 1.6.3-12.el8 appstream 246 k apr-util-devel x86_64 1.6.1-6.el8 appstream 86 k cyrus-sasl-devel x86_64 2.1.27-5.el8 baseos 128 k expat-devel x86_64 2.2.5-4.el8 baseos 55 k libdb-devel x86_64 5.3.28-42.el8_4 appstream 47 k openldap-devel x86_64 2.4.46-18.el8 baseos 811 k Transaction Summary ====================================================================================== Install 7 Packages Upgrade 3 Packages Total download size: 2.8 M Is this ok [y/N]: y
Placez-vous dans le sous-répertoire native et lancez les commandes pour effectuer la compilation :
[root@centos8 tomcat-connectors-1.2.49-src]# which apxs /usr/bin/apxs [root@centos8 tomcat-connectors-1.2.49-src]# cd native/ [root@centos8 native]# ./configure --with-apxs=/bin/apxs ... [root@centos8 native]# make ... [root@centos8 native]# libtool --finish /usr/lib64/httpd/modules ... [root@centos8 native]# make install ...
Modifiez ensuite la directive ServerName du fichier /etc/httpd/conf/httpd.conf ainsi :
... # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 ServerName www.ittraining.loc:80 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. ...
et ajoutez les directives suivantes à la fin du fichier, en dessous de la directive IncludeOptional afin de prendre en compte mod_jk et sa configuration :
... # Load config files in the "/etc/httpd/conf.d" directory, if any. IncludeOptional conf.d/*.conf LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel info JkMount /docs/* worker1 JkMount /docs worker1
Les différentes directives Apache utilisables avec mod_jk sont :
Directive | Description |
---|---|
JkWorkersFile | Spécifie le nom et l'emplacement du fichier de configuration du module nommé workers.properties par convention. Le chemin peut être absolu ou rélatif à l'installation d'Apache. |
JkWorkerProperty | L'utilisation de cette directive est mutuellement exclusive avec l'utilisation de la directive JkWorkersFile. Elle permet de définir les directives du fichier workers.properties directement dans le fichier httpd.conf sous la forme JkWorkerProperty <Directive> avec une directive par ligne. Chaque ligne doit donc commencer par JkWorkerProperty. |
JkLogFile | Spécifie le nom et l'emplacement du fichier de journalisation du module. Le chemin peut être absolu ou relatif à l'installation d'Apache. |
JkLogLevel | Spécifie le niveau de journalisation du module. Les valeurs ici peuvent être trace, debug, info, warn et error. Le fonctionnement est similaire à syslog dans la mesure où si la valeur est info alors tous les messages des niveaux info, warn et error seront journalisés. |
JkMount | Spécifie l'association d'un contexte d'application Tomcat avec un travailleur. Autrement dit, cette directive spécifie quelles sont les ressources d'une application Tomcat accessibles en passant par Apache. La syntaxe est JkMount <URL> <Nom du Travailleur>. |
JkUnMount | Spécifie une interdiction de redirection de requêtes vers une ressource d'une application Tomcat. La syntaxe est JkUnMount <URL> <Nom du Travailleur>. Notez que cette directive est prioritaire par rapport à la directive JkMount. |
JkAutoAlias | Spécifie un alias entre le répertoire des applications de Tomcat et le répertoire de publication des fichiers statiques d'Apache. De cette façon, les deux serveurs partagent un répertoire de publication unique. |
JkLogStampFormat | Spécifie le format de la date inscrite dans le fichier de journalisation du module en utilisant des séquences de contrôle, par exemple, JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“. |
JkExtractSSL | Spécifie que le module peut transmettre les informations SSL vers le serveur Tomcat. |
JkHTTPSIndicator | Spécifie le nom de la variable Apache contenant l'indication SSL. |
JkCERTSIndicator | Spécifie le nom de la variable Apache contenant le certificat SSL. |
JkSESSIONIndicator | Spécifie le nom de la variable Apache contenant l'identifiant de session SSL. |
Modifiez ensuite le fichier /etc/hosts pour la prise en charge du nom de notre serveur :
[root@centos8 native]# vi /etc/hosts [root@centos8 native]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.2.45 www.ittraining.loc
Créez ensuite le fichier /etc/httpd/conf/workers.properties :
[root@centos8 native]# cd ~ [root@centos8 ~]# vi /etc/httpd/conf/workers.properties [root@centos8 ~]# cat /etc/httpd/conf/workers.properties worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=127.0.0.1 worker.worker1.port=8009
Décommentez les lignes concernant le connecteur dans le fichier /usr/tomcat10/conf/server.xml :
... <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector protocol="AJP/1.3" address="127.0.0.1" port="8009" redirectPort="8443" secretRequired="false" /> ...
Redémarrez ensuite les serveurs httpd et tomcat :
[root@centos8 ~]# systemctl restart httpd [root@centos8 ~]# cd /usr/tomcat10/bin/ [root@centos8 bin]# ./shutdown.sh Using CATALINA_BASE: /usr/tomcat10 Using CATALINA_HOME: /usr/tomcat10 Using CATALINA_TMPDIR: /usr/tomcat10/temp Using JRE_HOME: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 Using CLASSPATH: /usr/tomcat10/bin/bootstrap.jar:/usr/tomcat10/bin/tomcat-juli.jar Using CATALINA_OPTS: [root@centos8 bin]# ./startup.sh Using CATALINA_BASE: /usr/tomcat10 Using CATALINA_HOME: /usr/tomcat10 Using CATALINA_TMPDIR: /usr/tomcat10/temp Using JRE_HOME: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 Using CLASSPATH: /usr/tomcat10/bin/bootstrap.jar:/usr/tomcat10/bin/tomcat-juli.jar Using CATALINA_OPTS: Tomcat started.
Vérifiez maintenant le bon fonctionnement d'Apache et de Tomcat en consultant les liens suivants :
[root@centos7 bin]# lynx --dump http://www.ittraining.loc [root@centos7 bin]# lynx --dump http://www.ittraining.loc:8080 [root@centos7 bin]# lynx --dump http://www.ittraining.loc/docs/
Important : Notez qu'en consultant l'adresse http://www.i2tch.loc/docs/ vous obtenez la même page que lors de votre consultation de l'adresse http://www.i2tch.loc:8080. Ceci implique que le serveur Apache est maintenant un serveur frontal pour le serveur Tomcat 10.
Créer un Service Systemd pour Tomcat
Créez un utilisateur tomcat :
[root@centos8 bin]# useradd -M -s /bin/nologin -d /usr/tomcat10 tomcat
Naviguez à votre répertoire $CATALINA_HOME :
[root@centos8 bin]# cd .. [root@centos8 tomcat10]#
Modifiez les droits sur certains fichiers et répertoires :
[root@centos8 tomcat10]# chgrp -R tomcat conf [root@centos8 tomcat10]# chmod g+rwx conf [root@centos8 tomcat10]# chmod g+r conf/* [root@centos8 tomcat10]# chown -R tomcat logs/ temp/ webapps/ work/ [root@centos8 tomcat10]# chgrp -R tomcat bin [root@centos8 tomcat10]# chgrp -R tomcat lib [root@centos8 tomcat10]# chmod g+rwx bin [root@centos8 tomcat10]# chmod g+r bin/*
Créez le fichier de service /etc/systemd/system/tomcat.service :
[root@centos8 tomcat10]# vi /etc/systemd/system/tomcat.service [root@centos8 tomcat10]# cat /etc/systemd/system/tomcat.service # Systemd unit file for tomcat [Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME="/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64" Environment=CATALINA_PID=/usr/tomcat10/temp/tomcat.pid Environment=CATALINA_HOME=/usr/tomcat10/ Environment=CATALINA_BASE=/usr/tomcat10/ Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom' ExecStart=/usr/tomcat10/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID User=tomcat Group=tomcat [Install] WantedBy=multi-user.target
Redémarrez systemd :
[root@centos8 tomcat10]# systemctl daemon-reload
Arrêtez Tomcat :
[root@centos8 tomcat10]# cd bin [root@centos8 bin]# ./shutdown.sh Using CATALINA_BASE: /usr/tomcat10 Using CATALINA_HOME: /usr/tomcat10 Using CATALINA_TMPDIR: /usr/tomcat10/temp Using JRE_HOME: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64 Using CLASSPATH: /usr/tomcat10/bin/bootstrap.jar:/usr/tomcat10/bin/tomcat-juli.jar Using CATALINA_OPTS:
Testez le service tomcat :
[root@centos8 bin]# systemctl start tomcat
Vérifiez que le Tomcat a démarré :
[root@centos8 bin]# ps aux | grep tomcat tomcat 59078 13.6 1.1 5723232 180292 ? Sl 10:11 0:03 /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin/java -Djava.util.logging.config.file=/usr/tomcat10//conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Xms512M -Xmx1024M -server -XX:+UseParallelGC -Dignore.endorsed.dirs= -classpath /usr/tomcat10//bin/bootstrap.jar:/usr/tomcat10//bin/tomcat-juli.jar -Dcatalina.base=/usr/tomcat10/ -Dcatalina.home=/usr/tomcat10/ -Djava.io.tmpdir=/usr/tomcat10//temp org.apache.catalina.startup.Bootstrap start root 59136 0.0 0.0 12136 1104 pts/0 S+ 10:12 0:00 grep --color=auto tomcat [root@centos8 bin]# systemctl status tomcat ● tomcat.service - Apache Tomcat Web Application Container Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disab> Active: active (running) since Tue 2023-10-03 10:11:55 EDT; 35s ago Process: 59071 ExecStart=/usr/tomcat10/bin/startup.sh (code=exited, status=0/SUCCES> Main PID: 59078 (java) Tasks: 49 (limit: 100949) Memory: 162.9M CGroup: /system.slice/tomcat.service └─59078 /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/bin/ja> Oct 03 10:11:55 centos8.ittraining.loc systemd[1]: Starting Apache Tomcat Web Applica> Oct 03 10:11:55 centos8.ittraining.loc systemd[1]: Started Apache Tomcat Web Applicat> [root@centos8 bin]#
Dernièrement vérifiez que les serveur Tomcat est bien démarré sous la responsabilité de l'utilisateur tomcat :
[root@centos8 bin]# pgrep -u tomcat 59078
MariaDB
Présentation
MariaDB est un fork de MySQL et est inclut dans les dépôts de CentOS 8.
Installation
Pour installer MariaDB, utilisez yum :
[root@centos8 bin]# cd ~ [root@centos8 ~]# dnf install mariadb mariadb-server Last metadata expiration check: 2:58:07 ago on Tue 03 Oct 2023 07:16:01 EDT. Dependencies resolved. ====================================================================================== Package Arch Version Repo Size ====================================================================================== Installing: mariadb x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 6.0 M mariadb-server x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 16 M Installing dependencies: mariadb-common x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 64 k mariadb-connector-c x86_64 3.1.11-2.el8_3 appstream 200 k mariadb-connector-c-config noarch 3.1.11-2.el8_3 appstream 15 k mariadb-errmsg x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 234 k perl-DBD-MySQL x86_64 4.046-3.module_el8.3.0+419+c2dec72b appstream 156 k Installing weak dependencies: mariadb-backup x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 6.1 M mariadb-gssapi-server x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 51 k mariadb-server-utils x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d appstream 1.1 M Enabling module streams: mariadb 10.3 perl-DBD-MySQL 4.046 Transaction Summary ====================================================================================== Install 10 Packages Total download size: 30 M Installed size: 153 M Is this ok [y/N]: y
Ensuite démarrez votre serveur MariaDB :
[root@centos8 ~]# systemctl status mariadb.service ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: > Active: inactive (dead) Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ [root@centos8 ~]# systemctl enable mariadb.service Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service. [root@centos8 ~]# systemctl start mariadb.service [root@centos8 ~]# systemctl status mariadb.service ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2023-10-03 10:17:52 EDT; 6s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 61941 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS) Process: 61796 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS) Process: 61770 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 61909 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 100949) Memory: 83.1M CGroup: /system.slice/mariadb.service └─61909 /usr/libexec/mysqld --basedir=/usr Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: MySQL manual for more instructions. Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: Please report any problems at http://mariadb.org/jira Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: The latest information about MariaDB is available at http://mariadb.org/. Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: You can find additional information about the MySQL part at: Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: http://dev.mysql.com Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: Consider joining MariaDB's strong and vibrant community: Oct 03 10:17:52 centos8.ittraining.loc mysql-prepare-db-dir[61796]: https://mariadb.org/get-involved/ Oct 03 10:17:52 centos8.ittraining.loc mysqld[61909]: 2023-10-03 10:17:52 0 [Note] /usr/libexec/mysqld (mysqld 10.3.28-MariaDB) starting as process 61909 ... Oct 03 10:17:52 centos8.ittraining.loc systemd[1]: Started MariaDB 10.3 database server.
Configuration
Lors de l'installation MariaDB n'a pas de mot de passe attribué à l'utilisateur root. Créez donc le mot de passe fenestros puis testez la connexion à MariaDB :
[root@centos8 ~]# mysqladmin -u root password fenestros [root@centos8 ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@centos8 ~]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.3.28-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> exit Bye [root@centos8 ~]#
OpenLDAP
Présentation
LDAP est une abréviation de Lighweight Directory Access Protocol. Comme son nom indique, LDAP est un service d'annuaire.
Un service d'annuaire est une base de données spécialisée optimisée pour la consultation. Certains services d'annuaire peuvent être locaux tandis que d'autres sont appelés distribués. Un bon exemple d'une service d'annuaire distribué est le DNS.
L'installation du serveur OpenLDAP ne peut être réussie que dans le cas où le support pour les bases de données BerkeleyDB soit installé au préalable.
Installation
Pour installer le serveur OpenLDAP, utilisez la commande dnf :
[root@centos8 ~]# dnf install openldap-servers openldap-clients openldap Last metadata expiration check: 3:04:13 ago on Tue 03 Oct 2023 07:16:01 EDT. Package openldap-2.4.46-18.el8.x86_64 is already installed. Dependencies resolved. ================================================================================================================================================================================================================== Package Architecture Version Repository Size ================================================================================================================================================================================================================== Installing: openldap-clients x86_64 2.4.46-18.el8 baseos 202 k openldap-servers x86_64 2.4.46-18.el8 powertools 2.2 M Transaction Summary ================================================================================================================================================================================================================== Install 2 Packages Total download size: 2.4 M Installed size: 5.4 M Is this ok [y/N]: y
Ensuite démarrez votre serveur OpenLDAP :
[root@centos8 ~]# systemctl status slapd ● slapd.service - OpenLDAP Server Daemon Loaded: loaded (/usr/lib/systemd/system/slapd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:slapd man:slapd-config man:slapd-hdb man:slapd-mdb file:///usr/share/doc/openldap-servers/guide.html [root@centos8 ~]# systemctl enable slapd Created symlink /etc/systemd/system/openldap.service → /usr/lib/systemd/system/slapd.service. Created symlink /etc/systemd/system/multi-user.target.wants/slapd.service → /usr/lib/systemd/system/slapd.service. [root@centos8 ~]# systemctl start slapd [root@centos8 ~]# systemctl status slapd ● slapd.service - OpenLDAP Server Daemon Loaded: loaded (/usr/lib/systemd/system/slapd.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2023-10-03 10:22:09 EDT; 8s ago Docs: man:slapd man:slapd-config man:slapd-hdb man:slapd-mdb file:///usr/share/doc/openldap-servers/guide.html Process: 62980 ExecStart=/usr/sbin/slapd -u ldap -h ldap:/// ldaps:/// ldapi:/// (code=exited, status=0/SUCCESS) Process: 62966 ExecStartPre=/usr/libexec/openldap/check-config.sh (code=exited, status=0/SUCCESS) Main PID: 62982 (slapd) Tasks: 2 (limit: 100949) Memory: 3.2M CGroup: /system.slice/slapd.service └─62982 /usr/sbin/slapd -u ldap -h ldap:/// ldaps:/// ldapi:/// Oct 03 10:22:09 centos8.ittraining.loc systemd[1]: Starting OpenLDAP Server Daemon... Oct 03 10:22:09 centos8.ittraining.loc runuser[62969]: pam_unix(runuser:session): session opened for user ldap by (uid=0) Oct 03 10:22:09 centos8.ittraining.loc runuser[62969]: pam_unix(runuser:session): session closed for user ldap Oct 03 10:22:09 centos8.ittraining.loc slapd[62980]: @(#) $OpenLDAP: slapd 2.4.46 (Aug 10 2021 05:11:20) $ mockbuild@x86-02.mbox.centos.org:/builddir/build/BUILD/openldap-2.4.46/openldap-2.4.46/servers/slapd Oct 03 10:22:09 centos8.ittraining.loc slapd[62982]: slapd starting Oct 03 10:22:09 centos8.ittraining.loc systemd[1]: Started OpenLDAP Server Daemon.
Copyright © 2023 Hugh Norris.