Aktionen

IONOS Mietserver Ubuntu 24.04 - Einrichtung ISPConfig

Aus znilwiki

Changelog:

  • 22.06.2024 erste Version

Vorwort

Meine Homepage läuft schon seit ein paar Jahren (2021) auf einem virtuellen Server bei IONOS.
Am 22.06.2024 habe ich einen neuen "VPS 2-2-80" Server bei IONOS angemietet. Aus verschiedenen Gründen:

  • Durch den Neuabschluss zahle ich nur 4€ statt 5€ im Monat
  • Bequeme Migration von Ubuntu 20.04 auf 24.04 da beides parallel läuft
  • Die Firewall-Richtlinien über das https://cloudpanel.ionos.de/ gefallen mir gut
  • Backup per VeeamAgent für Linux hat sich auch bei den neueren VMs auf "RedHat Virtualization (aka virtio)" als brauchbar herausgestellt.

Um die Einrichtung auch für das nächste man zu Beschleunigen, schreibe ich diesmal auch wirklich alles auf was ich mache :-)

Als Basis habe ich Ubuntu 24.04 LTS gewählt, nach ein paar Minuten war der Server fertig und ich konnte das erste mal per SSH auf das System.


Sprache Umstellen

Default ist das Ubuntu Englisch, inklusive Englischer Tastatur.
Das mit der Tastatur ist prinzipiell bei SSH Zugriff egal, aber es gibt auch eine KVM-Konsole bzw. beim Restore unter VMware ist auch erst einmal die Konsole.

dpkg-reconfigure keyboard-configuration

und dann

Generic 105-key PC => German => German => The default for the keyboard layout => No compose key

Und noch die Sprache

dpkg-reconfigure locales

und dann

de_DE.UTF-8 UTF-8 => de_DE.UTF-8

nano & Co auch auf deutsch

apt install -y language-pack-de

Prompt anpassen

nano .bashrc

und folgende Zeilen anpassen:

force_color_prompt=yes
alias ll='ls -alFh'

macht den Prompt farbig und alle Größenangaben sind "Human readable", also in Kilobyte, Megabyte etc. statt in Bytes.
Und ganz unten noch folgendes anhängen:

# Alle SSH Sitzungen teilen sich die Bash-History
# Keine Duplikate oder leeren Zeilen
HISTCONTROL=ignoredups:ignorespace:erasedups
# An die History Datei anhängen, nicht überschreiben
shopt -s histappend
# Maximale Anzahl Zeilen und/oder Dateigröße (je nachdem was zuerst eintrifft)
HISTSIZE=50000
HISTFILESIZE=50000
# Nach jeden abgesetzen Befehl diesen an die History anhängen und diese neu einlesen
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'n'}history -a; history -c; history -r"

System umbennen

ionos-web02 soll der neue Name des Systems sein.

hostnamectl set-hostname ionos-web02

und noch

nano /etc/hosts

und dort die 127.0.1.1 Zeile anpassen:

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 ionos-web02 ionos-web02.znil.org
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Das ISPConfig-Installationsskript besteht auf einen FQDN-Namen für 127.0.1.1!
Der Name muss nicht auflösbar sein.
Nach einem reboot muss das in etwa so bei euch aussehen:

root@ionos-web02:~# hostname
ionos-web02
root@ionos-web02:~# hostname -f
ionos-web02.znil.org

Anmeldung des root per SSH verbieten

Per Default haben wir eine root-Anmeldung per SSH und Passwort.
Ich melde mich per SSH aber immer per SSH-Key an.
Den SSH-Key fügen wir in folgende Datei ein:

nano ~/.ssh/authorized_keys2

Speichern und dann testen ob die Anmeldung per SSH-Key funktioniert.
Wenn ja:

nano /etc/ssh/sshd_config

und ganz nach unten scrollen, da wurde bei mir die Zeile

PermitRootLogin yes

angehängt die wir mit F9 einfach löschen (oder an jeder anderen Stelle wo diese stehen würde)
Damit gilt automatisch der Default Wert PermitRootLogin prohibit-password
Die Gegenprobe schadet natürlich nicht (also ob es wirklich nicht mehr per Passwort geht)


Zeitzone setzen / Zeitserver setzen

Der Befehl

date

spuckt noch eine falsche Uhrzeit aus, die richtige Zeitzone setzen wir mit

timedatectl set-timezone Europe/Berlin

Als Zeitserver wird im Moment noch

ntp.ubuntu.com

genommen, das ändere ich wie folgt:

nano /etc/systemd/timesyncd.conf

und folgende Zeile einfügen / ändern:

[Time]
NTP=de.pool.ntp.org
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60

Updates einspielen / System aktualisieren

Das mache ich immer (auch später) mit folgendem Einzeiler:

apt update && apt dist-upgrade -y && apt autoremove -y

und ein

reboot

danach schadet nicht.


ISPConfig Installieren

Jetzt sind wir schon soweit das wir ISPConfig installieren können.
Früher habe ich das immer nach einen der diversen "The Perfect Server" Anleitungen installiert:

https://www.ispconfig.org/documentation/

Inzwischen gibt es einen automatischen Installer der das für uns übernimmt:

https://www.howtoforge.com/ispconfig-autoinstall-debian-ubuntu/

Die Vorarbeiten die man machen soll, haben wir schon erledigt.
Da ich einige Parameter anpassen möchte, starte ich es mit entsprechenden Parametern:
Die Hilfe bekommen wir per

wget -O - https://get.ispconfig.org | sh -s -- --help

Da werden - obwohl wir nur die Hilfe aufrufen - schon einige Pakete nachinstalliert.
Am Ende steht da die Hilfe:

**********************************************************************************************************************************************************************************************ISPConfig 3 Autoinstaller
**********************************************************************************************************************************************************************************************

Usage: ispc3-ai.sh [<argument>] [...]

This script automatically installs all needed packages for an ISPConfig 3 setup using the guidelines from the "Perfect Server Setup" howtos on www.howtoforge.com.

Possible arguments are:
    --help          Show this help page.
    --debug         Enable verbose logging (logs each command with the exit code).
    --channel       Choose the channel to use for ISPConfig: --channel=<stable|dev>
                    "stable" is the latest ISPConfig release available on www.ispconfig.org
                    "dev" is the latest dev-branch from the ISPConfig git repository: https://git.ispconfig.org/ispconfig/ispconfig3/tree/develop
                    The dev channel might contain bugs and less-tested features and should only be used in production by very experienced users.
    --lang          Use language for ISPConfig installation. Specify with --lang=en|de (only en (English) and de (German) supported currently).
    --interactive   Don't install ISPConfig in non-interactive mode.
                    This is needed if you want to use expert mode, e.g. to install a slave server that shall be integrated into an existing multiserver setup.
    --use-nginx     Use NGINX webserver instead of Apache2.
    --use-amavis    Use Amavis instead of Rspamd for mail filtering.
    --use-unbound   Use unbound instead of bind9 for local resolving. Only allowed if --no-dns is set.
    --use-php       Use specific PHP versions, comma separated, instead of installing multiple PHP, e.g. --use-php=7.4,8.0 (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 and 8.3 available).
                    --use-php=system disables the sury repository and just installs the system's default PHP version.
                    --use-php while omitting the argument, uses all versions.
    --use-ftp-ports This option sets the passive port range for pure-ftpd. You have to specify the port range separated by hyphen, e.g. --use-ftp-ports=40110-40210.
                    If not provided the passive port range will not be configured.
    --use-certbot   Use Certbot instead of acme.sh for issuing Let's Encrypt certificates. Not advised unless you are migrating from an old server that uses Certbot.
    --no-web        Do not use ISPConfig on this server to manage webserver setting and don't install nginx/apache or pureftpd.
                    This will also prevent installing an ISPConfig UI and implies --no-roundcube as well as --no-pma.
    --no-mail       Do not use ISPConfig on this server to manage mailserver settings.
                    This will install Postfix for sending system mails, but not dovecot and not configure any settings for ISPConfig mail. It implies --no-mailman.
    --no-dns        Do not use ISPConfig on this server to manage DNS entries. Bind will be installed for local DNS caching / resolving only.
    --no-local-dns  Do not install local DNS caching / resolving via bind.
    --no-firewall   Do not install ufw and tell ISPConfig to not manage firewall settings on this server.
    --no-roundcube  Do not install roundcube webmail.
    --roundcube     Install Roundcube even when --no-mail is used. Manual configuration of Roundcube config is needed.
    --no-pma        Do not install phpMyAdmin on this server.
    --no-mailman    Do not install Mailman mailing list manager.
    --no-quota      Disable file system quota.
    --no-ntp        Disable NTP setup.
    --no-jailkit    Do not install jailkit.
    --no-ftp        Do not install Pure-FTPd server.
    --monit         Install Monit and set it up to monitor installed services. Supported services: Apache2, NGINX, MariaDB, pure-ftpd-mysql, php-fpm, ssh, named, Postfix, Dovecot, rspamd.
    --monit-alert-email
                    Set up alerts for Monit to be sent to given e-mail address. e.g. --monit-alert-email=me@example.com.
    --ssh-port      Configure the SSH server to listen on a non-default port. Port number must be between 1 and 65535 and can not be in use by other services. e.g. --ssh-port=64.
    --ssh-permit-root
                    Configure the SSH server whether or not to allow root login: --ssh-permit-root=<yes|without-password|no>, e.g. --ssh-permit-root=without-password.
    --ssh-password-authentication
                    Configure the SSH server whether or not to allow password authentication: --ssh-password-authentication=<yes|no>, e.g. -ssh-password-authentication=no.
    --ssh-harden    Configure the SSH server to have a stronger security config.
    --unattended-upgrades
                    Install UnattendedUpgrades. You can add extra arguments for automatic cleanup and automatic reboots when necessary: --unattended-upgrades=autoclean,reboot (or only one of
                    them).
    --i-know-what-i-am-doing
                    Prevent the autoinstaller to ask for confirmation before continuing to reconfigure the server.

Ich nutze ISPConfig nur für mich alleine. Aber warum dann? Weil es bequem ist, jede Webseite läuft dann unter ihrem eigenen, eingeschränkten Benutzer, ich kann pro Webseite die PHP-Version einstellen (oder abschalten), automatisch Let`s Encrypt Zertifikate anfordern lassen usw.
Aber ich brauche - Stand 22.06.2024 - keinen Mailserver / Webmail / FTP / DNS-Server / NTP-Setup.
Ich installiere ISPConfig aif Englisch (ja, ich weis, wir haben doch gerade extra alles auf Deutsch umgestellt), empfinde ich als einfacher.
Ok, mein Aufruf sieht wie folgt aus:

wget -O - https://get.ispconfig.org | sh -s -- --lang=en --no-mail --no-dns --no-local-dns --no-firewall --no-roundcube --no-quota --no-ntp --no-ftp

Erklärung

--no-mail         : Installiert nur Postfix um Systemmeldungen zu versenden, aber keine zusätzlichen Pakete oder die Konfiguration über ISPConfig
--no-dns          : Keine Verwaltung von DNS-Einträgen über ISPConfig
--no-local-dns    : und auch keinen Bind-DNS-Server installieren, wir fragen ganz norme externe DNS-Server ab
--no-firewall     : die Firewall nicht aktivieren (Ich nutze die IONOS Firewall davor) 
--no-roundcube    : Den Roundcube Webmailer nicht installieren
--no-quota        : Keine Speicherplatzbegrenzungen pro Benutzer verwenden
--no-ntp          : Zeitserver nicht konfigurieren
--no-ftp          : keinen FTP-Server installieren