Skip to content

PostfixAdmin installieren (Debian/Ubuntu)

Da PostfixAdmin eine PHP-Anwendung ist, ist ein Webserver erforderlich. Wir werden Apache2 mit PHP und MariaDB verwenden. Die benötigten PHP Pakete installieren wir wie folgt.

apt update
apt install apache2 php php-mysqli php-intl php-mbstring php-xml \
             php-curl php-zip mariadb-server

Nun erstellen wir uns eine MySQL Datenbank postfixadmin und einen dazugehörigen Benutzer postfixadmin. Als Platzhalter your_secret_password muss natürlich das echte Passwort rein.

CREATE DATABASE postfixadmin CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'postfixadmin'@'localhost' IDENTIFIED BY 'your_secret_password';
GRANT ALL PRIVILEGES ON postfixadmin.* TO 'postfixadmin'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Nun laden wir uns PostfixAdmin herunter und installieren es wie folgt.

cd /var/www/

wget https://github.com/postfixadmin/postfixadmin/archive/refs/tags/postfixadmin-4.0.1.tar.gz
tar xzf postfixadmin-4.0.1.tar.gz
rm postfixadmin-4.0.1.tar.gz

mv postfixadmin-postfixadmin-4.0.1 postfixadmin-4.0.1
ln -s postfixadmin-4.0.1 postfixadmin

mkdir -p postfixadmin/templates_c
chown -R www-data:www-data postfixadmin-4.0.1
chmod 750 postfixadmin-4.0.1

Dann erstellen wir uns unsere Konfiguration für PostfixAdmin. Dabei müssen wir your_secret_password wieder mit dem Passwort des Datenbank Benutzer ersetzen. Auch example.com ersetzen wir durch unsere Domain.

cat <<CONFIG | tee /var/www/postfixadmin/config.local.php >/dev/null
<?php
$CONF['configured'] = true;
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'your_secret_password';
$CONF['database_name'] = 'postfixadmin';
$CONF['database_port'] = 3306;

$CONF['encrypt'] = 'php_crypt:SHA512::{SHA512-CRYPT}';
$CONF["admin_email"] = "PostfixAdmin <postmaster@example.com>";

$CONF['password_validation'] = 'regex';
// min 1 Großbucstaben, min 1 Kleinbuchstaben, min 1 Ziffer, optional min 1 Sonderzeichnen, min 8 Zeichen lang
$CONF['password_validation_regex'] = [
    '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z0-9]).{8,}$/'
        => 'password_too_weak'
];

$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
?>
CONFIG

Nun führen wir folgendes Skript aus um das Datenbankschema zu installieren.

php /var/www/postfixadmin/public/upgrade.php

Da die Datenbank nun fertig ist, ist es möglich, den ersten Superadmin admin über die CLI-Tools zu erstellen.

bash /var/www/postfixadmin/scripts/postfixadmin-cli admin add

Als Letzen Schritt erstellen wir uns einen VirtualHost wo wir als DocumentRoot /var/www/postfixadmin/public verwenden.