Configuration SSL avec Apache2 et Let's Encrypt
Prérequis
- Une installation d'apache2 fonctionnelle
- Un virtualhost apache fonctionnelle sur le port 80
Info
Pour les commandes à venir, il est nécéssaire de remplacer {domain-name.fr}
par votre nom de domaine.
Installation de Let's Encrypt
Activation du modules SSL apache
Redémarrage d'apache
Installation du certificat
Création du certificat en mode non intéractif
Mise en place de la conf SSL apache
/etc/apache2/sites-available/{domain.com}.conf
<VirtualHost *:80>
ServerName {domain-name.fr}
ErrorLog ${APACHE_LOG_DIR}/{domain-name.fr}-error.log
CustomLog ${APACHE_LOG_DIR}/{domain-name.fr}-access.log combined
RewriteEngine On
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName {domain-name.fr}
ServerAlias {domain-name.fr}
# La configuration apache
# ...
# Le chemin vers les logs apache
ErrorLog ${APACHE_LOG_DIR}/{domain-name.fr}-error.log
CustomLog ${APACHE_LOG_DIR}/{domain-name.fr}-access.log combined
# SSL
SSLCertificateFile /etc/letsencrypt/live/{domain-name.fr}-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/{domain-name.fr}-0001/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Ne pas oublier de placer votre configuration à l'intérieur de celle-ci et de modifier {domain-name.fr}
par votre nom de domaine.
Redémarrage d'apache
Renouvellement automatique du certificat
À la main sur le serveur
Info
Une tache cron est déjà parametré pour le renouvellement des certificats par certbot dans ce fichier /etc/cron.d/certbot
Suppression d'un certificat
Suppression du certificat
Supression des liens vers le certificat dans la conf apache
Redémarrage d'apache