Server Installation · 4 min read · Feb 03, 2026
Debian Sarge (3.1) mit Ruby on Rails und Apache 2 mit FastCGI - Seite 3
MySQL installieren
apt-get install mysql-server mysql-client libmysqlclient12-devSetzen Sie Ihr MySQL-Root-Passwort
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpasswordWenn Sie netstat -tap ausführen, sollten Sie jetzt eine Zeile wie diese sehen:
| tcp 0 0 localhost.localdo:mysql *:* |
was bedeutet, dass MySQL auf 127.0.0.1 auf Port 3306 zugänglich ist. Sie können zum nächsten Abschnitt (Postfix) gehen. Wenn Sie diese Zeile nicht sehen, bearbeiten Sie /etc/mysql/my.cnf und kommentieren Sie skip-networking aus:
| # skip-networking |
Wenn Sie möchten, dass MySQL auf allen verfügbaren IP-Adressen hört, bearbeiten Sie /etc/mysql/my.cnf und kommentieren Sie bind-address = 127.0.0.1 aus:
| # bind-address = 127.0.0.1 |
Wenn Sie /etc/mysql/my.cnf bearbeiten mussten, müssen Sie MySQL neu starten:
/etc/init.d/mysql restartPostfix/POP3/IMAP installieren
Um Postfix mit SMTP-AUTH und TLS sowie einen POP3-Server, der auch POP3s (Port 995) und einen IMAP-Server, der auch IMAPs (Port 993) unterstützt, zu installieren, führen Sie die folgenden Schritte aus:
apt-get install postfix postfix-tls libsasl2 sasl2-bin libsasl2-modules ipopd-ssl uw-imapd-sslBeantworten Sie die Eingabeaufforderungen:
Fortfahren mit der Installation von libc-client ohne Maildir-Unterstützung? Antwort Nein
Auf welchen Ports soll der Server hören? Antwort pop3 und pop3s
Portauswahl erzwingen? Antwort Nein
Auf welchen Ports soll der Server hören? Antwort imap2 und imaps
Portauswahl erzwingen? Antwort Nein
Allgemeine Art der Konfiguration? Antwort Internet Site
Wohin soll die Mail für root gehen? Antwort NONE
Mailname? Antwort server1.example.com
Andere Ziele, um Mail zu akzeptieren? (leer für keine) Antwort server1.example.com, localhost.example.com, localhost
Erzwingen Sie synchrone Updates in der Mail-Warteschlange? Antwort Nein
Jetzt konfigurieren Sie Postfix:
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.confSSL einrichten
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024Sie müssen ein Passwort für die smtpd.key von 4 bis 8191 Zeichen eingeben
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csrFüllen Sie die Zertifikatsanforderung aus oder nehmen Sie die Standardwerte
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crtSie müssen das Passwort eingeben, das Sie zuvor für die smtpd.key eingegeben haben
openssl rsa -in smtpd.key -out smtpd.key.unencryptedSie müssen das Passwort eingeben, das Sie zuvor für die smtpd.key eingegeben haben
mv -f smtpd.key.unencrypted smtpd.keyopenssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650Füllen Sie die Zertifikatsanforderung aus oder nehmen Sie die Standardwerte
Machen Sie weitere Postfix-Konfigurationen
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'Die Datei /etc/postfix/main.cf sollte jetzt so aussehen:
joe /etc/postfix/main.cf| # Siehe /usr/share/postfix/main.cf.dist für eine kommentierte, vollständigere Version smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # Das Anhängen von .domain ist die Aufgabe des MUA. append_dot_mydomain = no # Kommentieren Sie die nächste Zeile aus, um "verzögerte Mail"-Warnungen zu generieren #delay_warning_time = 4h myhostname = server1.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = server1.example.com, localhost.example.com, localhost relayhost = mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom |
Postfix neu starten
/etc/init.d/postfix restartDie Authentifizierung erfolgt über saslauthd. Wir müssen ein paar Dinge ändern, um es richtig zum Laufen zu bringen. Da Postfix chrooted in /var/spool/postfix läuft, müssen wir Folgendes tun:
mkdir -p /var/spool/postfix/var/run/saslauthdJetzt müssen wir /etc/default/saslauthd bearbeiten, um saslauthd zu aktivieren. Entfernen Sie das # vor START=yes und fügen Sie die Zeile PARAMS="-m /var/spool/postfix/var/run/saslauthd -r" hinzu:
joe /etc/default/saslauthd| # Dies muss auskommentiert werden, bevor saslauthd automatisch ausgeführt wird START=yes PARAMS="-m /var/spool/postfix/var/run/saslauthd -r" # Sie müssen die Authentifizierungsmechanismen angeben, die Sie verwenden möchten. # Dies ist standardmäßig "pam" für PAM-Unterstützung, kann aber auch # "shadow" oder "sasldb" enthalten, wie folgt: # MECHANISMS="pam shadow" MECHANISMS="pam" |
Jetzt starten Sie saslauthd:
/etc/init.d/saslauthd startAls nächstes erstellen wir die Datei /etc/c-client.cf:
echo "Ich akzeptiere das Risiko" > /etc/c-client.cf echo "set disable-plaintext 0" >> /etc/c-client.cfJetzt starten Sie inetd neu:
/etc/init.d/inetd restartWenn wir das nicht tun, werden unsere POP3/IMAP-Anmeldungen fehlschlagen.
Um zu sehen, ob SMTP-AUTH und TLS jetzt richtig funktionieren, führen Sie den folgenden Befehl aus:
telnet localhost 25Nachdem Sie die Verbindung zu Ihrem Postfix-Mailserver hergestellt haben, geben Sie ein:
ehlo localhostWenn Sie die Zeilen sehen:
250-STARTTLSund
250-AUTHist alles in Ordnung.
Geben Sie ein:
quitum zur Shell des Systems zurückzukehren.
Courier-IMAP/Courier-POP3 mit Maildir-Unterstützung installieren
apt-get install courier-imap courier-imap-ssl courier-pop courier-pop-sslBeantworten Sie die Eingabeaufforderungen:
Verzeichnisse für die webbasierte Verwaltung erstellen? Antwort Nein
SSL-Zertifikat erforderlich Antwort OK
Konfigurieren Sie dann Postfix, um E-Mails an das Maildir eines Benutzers zuzustellen:
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restartErhalte neue Beiträge in deinem Posteingang.
Kein Spam. Jederzeit abmelden.