Apache HTTPD

Le serveur Apache HTTPD permet d’héberger des sites web et de fournir des services HTTP et HTTPS au sein de l’infrastructure.

Infrastructure Web — Apache HTTPD

Documentation complète d’installation et de configuration d’un serveur web Apache avec SSL

1 — Installation et Configuration Apache HTTPD

Installation et configuration du serveur web Apache

Installation des packages

dnf install httpd mod_ssl -y

Configuration du serveur

Modifier le nom de la machine et l’adresse d’écoute dans :

vi /etc/httpd/conf/httpd.conf

Modifier les lignes :

Listen 80
#ServerName www.example.com:80

Configuration attendue :

Listen *:80
ServerName web:80

2 — Gestion du service HTTPD

Démarrage et vérification du service

Démarrage du service

systemctl start httpd.service --now
systemctl enable httpd.service --now

Vérification du service

ss -atnp | grep httpd

Si le service fonctionne correctement, deux ports doivent être en écoute : 80 et 443.


3 — Ouverture des ports Firewall

Configuration des règles iptables

Configuration

vi /etc/sysconfig/iptables
-I INPUT 2 -p tcp --dport 80 -j ACCEPT
-I INPUT 3 -p tcp --dport 443 -j ACCEPT

Enregistrer :

systemctl reload iptables

Vérification

iptables -nvL

Résultat attendu

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target prot opt in out source destination         
   81  5840 ACCEPT all  --  * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
<span style="background-color:#fff3cd;">    0     0 ACCEPT tcp  --  * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80</span>
<span style="background-color:#fff3cd;">    0     0 ACCEPT tcp  --  * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443</span>
    0     0 ACCEPT icmp --  * * 0.0.0.0/0 0.0.0.0/0           
    0     0 ACCEPT all  --  lo * 0.0.0.0/0 0.0.0.0/0           
    0     0 ACCEPT tcp  --  * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
    0     0 REJECT all  --  * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

4 — Création du site web

Création et permissions du site

Création de la page d’accueil

vi /var/www/html/index.html

Exemple :

cc

Droits d’accès

chown apache.apache -R /var/www/html

Vérification

Tester avec curl :

curl 192.168.10.251

Vous devez voir le contenu de votre page web. Répéter la procédure sur le second serveur si nécessaire.


Serveur Apache HTTPD opérationnel