Mettre en place un serveur web Apache2 sur Debian avec une configuration fonctionnelle.
Prérequis
- Debian
- Accès root ou sudo
- Accès réseau
Installation
sudo apt update
sudo apt install apache2 -y
Démarrage du service
sudo systemctl start apache2
sudo systemctl enable apache2
Vérifier :
sudo systemctl status apache2
Test du serveur
Dans un navigateur :
http://IP_DU_SERVEUR
Tu dois voir la page “Apache2 Debian Default Page”
Arborescence utile
/var/www/html → racine web
/etc/apache2 → config Apache
/etc/apache2/sites-available
/etc/apache2/sites-enabled
Modifier la page web
sudo nano /var/www/html/index.html
Exemple minimal :
<h1>Serveur OK</h1>
<p>Apache fonctionne</p>
Recharger Apache
sudo systemctl reload apache2
Ouvrir le firewall (si actif)
Avec UFW :
sudo ufw allow "Apache"
sudo ufw reload
Vérifications
curl http://localhost
ss -tulnp | grep :80
Commandes utiles
sudo systemctl restart apache2
sudo systemctl stop apache2
sudo apache2ctl configtest
Problèmes fréquents
- Port 80 déjà utilisé
sudo ss -tulnp | grep :80
- Service non démarré
sudo systemctl status apache2
- Firewall bloquant
Suite logique
- Installer PHP
- Installer MariaDB
- Déployer WordPress
- Ajouter HTTPS (Let’s Encrypt)
Résultat
Apache est opérationnel
Serveur web prêt à héberger un site
