# SSL-Zertifikat mit Certbot installieren

Mit dieser Anleitung kannst du ganz einfach ein kostenloses **Let's Encrypt SSL-Zertifikat** über **Certbot** auf deinem Apache-Webserver installieren.

---

## 1. System aktualisieren

Führe zuerst ein Update und Upgrade aus:

```
apt update && apt upgrade -y
```

---

## 2. Notwendige Pakete installieren

Installiere Certbot und das Apache-Plugin:

```
apt install certbot python3-certbot-apache sudo -y
```

---

## 3. Apache Virtual Host konfigurieren

Öffne die Apache-Standardkonfiguration:

```
nano /etc/apache2/sites-available/000-default.conf
```

Füge deine Domain hinzu:

```apache
ServerName your_domain
ServerAlias www.your_domain
```

Anschließend den Apache-Webserver neu starten:

```
systemctl restart apache2
```

---

## 4. SSL-Zertifikat anfordern

Starte den Certbot-Dialog mit:

```
certbot --apache
```

Du wirst dabei Schritt für Schritt durch die Einrichtung geführt:

### Beispielausgabe:
```bash
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices):
you@your_domain
```

Dann akzeptiere die Nutzungsbedingungen (`A`) und entscheide, ob du deine E-Mail-Adresse mit der EFF teilen möchtest (`N`).

---

## 5. Domainauswahl und Einrichtung

Certbot fragt dich, für welche Domains das Zertifikat erstellt werden soll:

```bash
Which names would you like to activate HTTPS for?
1: your_domain
2: www.your_domain
Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown:
```

Wähle `2` für HTTPS-Umleitung:

```bash
Please choose whether or not to redirect HTTP traffic to HTTPS:
1: No redirect
2: Redirect - Make all requests redirect to secure HTTPS access.
Select the appropriate number [1-2] then [enter]: 2
```

---

## 6. Erfolgsmeldung

Nach Abschluss sollte diese Meldung erscheinen:

```bash
Congratulations! You have successfully enabled https://your_domain and
https://www.your_domain
```

---

## 7. Wichtige Pfade

Deine Zertifikatsdateien liegen hier:

```
/etc/letsencrypt/live/your_domain/fullchain.pem
/etc/letsencrypt/live/your_domain/privkey.pem
```

---

## 8. Zertifikatsstatus prüfen

```
systemctl status certbot.timer
```

Damit überprüfst du, ob der automatische Erneuerungsdienst aktiv ist.

---

## 9. Zertifikat testen (Dry-Run)

Mit diesem Befehl kannst du die automatische Erneuerung testen, ohne wirklich ein neues Zertifikat zu erstellen:

```
certbot renew --dry-run
```

---

✅ **Fertig!**
Deine Website ist nun per HTTPS erreichbar und das Zertifikat wird automatisch erneuert.
