Let’s encrypt (certbot) um eine Domain erweitern

Let’s encrypt bietet kostenlose Zertifikate zur Verschlüsselung an. In diesem Beispiel erweitern wir unser bestehendes Zertifikat um die Domain newexample.com. Das Vorgehen für eine Subdomain ist dasselbe. Mittels:

# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: example.com
    Serial Number: 1234567890acb1234567890abc1234567890
    Key Type: ECDSA
    Domains: example.com test.example.com example2.com example3.com
    Expiry Date: 2023-07-28 17:09:45+00:00 (VALID: 87 days)
    Certificate Path: /etc/letsencrypt/live/nyx7.ch/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/nyx7.ch/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

wird uns der Zertifikatsname mit allen zugehörenden Domains angezeigt. Möchten wir nun das bestehende Zertikikat um eine Domain oder Subdomain (newexample.com) erweitern, müssen wir das Zertifikat example.com für alle Domains und Subdomains erweitern.

Die Erweiterung des Zertifikates per expand:

# certbot --expand -d example.com,test.example.com,example2.com,example3.com,newexample.com
# certbot --expand -d example.com,test.example.com,example2.com,example3.com,newexample.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Renewing an existing certificate for example.com and 4 more domains

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/example.com/privkey.pem
This certificate expires on 2023-07-30.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for example.com to /etc/apache2/sites-enabled/000-default-le-ssl.conf
Successfully deployed certificate for test.example.com to /etc/apache2/sites-enabled/000-default-le-ssl.conf
Successfully deployed certificate for example2.com to /etc/apache2/sites-enabled/000-default-le-ssl.conf
Successfully deployed certificate for example3.com to /etc/apache2/sites-enabled/000-default-le-ssl.conf

We were unable to find a vhost with a ServerName or Address of newexample.com.
Which virtual host would you like to choose?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: 000-default-le-ssl.conf        | Multiple Names        | HTTPS | Enabled
2: 000-default.conf               |                       |       | Enabled
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Successfully deployed certificate for newexample.com to /etc/apache2/sites-enabled/000-default-le-ssl.conf
Your existing certificate has been successfully renewed, and the new certificate has been installed.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Um jedoch ein neues Zertifikat für die Domain zu bekommen, tippen wir:

# certbot certonly -d newexample.com

ein. Mehrere Domain und Subdomain werden durch ein Komma getrennt.

gesamte Domain weiterleiten per .htaccess

Wer seine gesamte Webseite umgezogen hat, setzt per .htaccess ein Weiterleitung von der alten Domain (example1.com) zur neuen Domain (example2.com)
Damit werden sämtliche Anfrage von der alten Domain auf die neue Domain permanent umgeleitet:

# Weiterleitung von example1.com nach example2.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^https://example1.com [NC]
RewriteRule ^(.*)$ https://example2.com/$1 [R=301,L]
</IfModule>

nachfolgende Weiterleitung behält alle indexierten URLs bei und leitet alles auf die neue Webseite example.com weiter. Hat eine Suchmaschine somit https://mydomain.com indexiert, zeigt diese Weiterleitung automatisch dann auf https://example.com und weist die Suchmaschine über die permanente Weiterleitung mittels 301 hin:

<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://example.com/$1 [R=301,L]
</IfModule>

Webserver (mit XAMPP)

XAMPP ist eine leicht zu installierende Apache-Distribution, die MariaDB, PHP und Perl enthält.
Gehe auf http://www.apachefriends.org/de/download.html

Dieses Tutorial bezieht sich auf die Installation von XAMPP unter Debian GNU/Linux und wurde unter Bullseye getestet.

Fährst Du mit der Maus über eine Prüfsumme (md5 oder sha1), wird dir diese angezeigt. Nach erfolgreichem Download kann die Prüfsumme ausgelesen werden:

$ sha1sum xampp-linux-*-installer.run
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN  xampp-linux-*-installer.run

Ist die Prüfsumme korrekt, kann mit der Installation begonnen werden. Die Datei wird zuerst ausführbar gemacht:

$ chmod 755 xampp-linux-*-installer.run

und anschliessend die Installationsroutine gestartet:

# ./xampp-linux-*-installer.run

Der XAMPP-Installer verlangt root-Rechte. Tippe dazu su – ein:

su -
Passwort: 
./xampp-linux-x64-8.1.1-2-installer.run
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want 
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] : Y

Is the selection above correct? [Y/n]: Y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: Y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.

XAMPP kann nun via Brower aufgerufen werden. Tippe dazu in die Adresszeile localhost ein.

Die Dienste müssen vorab jedoch gestartet werden. Xampp heisst unter Linux korrekterweise lampp:

# /opt/lampp/lampp start
Starting XAMPP for Linux 8.1.1-2...
XAMPP: Starting Apache.../opt/lampp/share/xampp/xampplib: Zeile 22: netstat: Kommando nicht gefunden.
/opt/lampp/share/xampp/xampplib: Zeile 22: netstat: Kommando nicht gefunden.
ok.
XAMPP: Starting MySQL.../opt/lampp/share/xampp/xampplib: Zeile 22: netstat: Kommando nicht gefunden.
ok.
XAMPP: Starting ProFTPD.../opt/lampp/share/xampp/xampplib: Zeile 22: netstat: Kommando nicht gefunden.
ok.

Die Meldung von netstat kann getrost ignoriert werden oder mit dem Paket net-tools behoben werden.

# apt install net-tools

jetzt startet XAMPP «fehlerfrei»

# /opt/lampp/lampp start
Starting XAMPP for Linux 8.1.1-2...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

Beendet wird XAMPP mit:

# /opt/lampp/lampp stop
Stopping XAMPP for Linux 8.1.1-2...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...ok.

>>> HINWEIS <<<
Das Verzeichnis von XAMPP befindet sich unter
/opt/lampp/htdocs
Um dauerhaft Besitzer dieses Verzeichnis zu werden, können die Besitzerrechte mit chown geändert werden. Tippe dazu:

# chown -cR BENUTZER /opt/lampp/htdocs

ein.