Server Setup · 5 min read · Oct 29, 2025

Der perfekte Server - CentOS 4.8 Server x86_64 [ISPConfig 2] - Seite 5

10 Postfix mit SMTP-AUTH und TLS

Jetzt installieren wir Postfix und Dovecot (Dovecot wird unser POP3/IMAP-Server sein):

yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot

Als nächstes konfigurieren wir SMTP-AUTH und TLS:

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_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
postconf -e 'mynetworks = 127.0.0.0/8'

Wir müssen /usr/lib64/sasl2/smtpd.conf bearbeiten, damit Postfix PLAIN- und LOGIN-Anmeldungen zulässt. Auf einem 32-Bit CentOS 4.8 müssen Sie die Datei /usr/lib/sasl2/smtpd.conf stattdessen bearbeiten. Es sollte so aussehen:

vi /usr/lib64/sasl2/smtpd.conf

| pwcheck_method: saslauthd mech_list: plain login |

Danach erstellen wir die Zertifikate für TLS:

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

Als nächstes konfigurieren wir Postfix für TLS:

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'

Dann setzen wir den Hostnamen in unserer Postfix-Installation (stellen Sie sicher, dass Sie server1.example.com durch Ihren eigenen Hostnamen ersetzen):

postconf -e 'myhostname = server1.example.com'

Nach diesen Konfigurationsschritten sollten Sie jetzt eine /etc/postfix/main.cf haben, die so aussieht (ich habe alle Kommentare entfernt):

cat /etc/postfix/main.cf

| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix mail_owner = postfix inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.2.10/samples readme_directory = /usr/share/doc/postfix-2.2.10/README_FILES smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination mynetworks = 127.0.0.0/8 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 myhostname = server1.example.com |

Standardmäßig bietet der Dovecot-Daemon von CentOS nur IMAP- und IMAPs-Dienste an. Da wir auch POP3 und POP3s möchten, müssen wir Dovecot entsprechend konfigurieren. Wir bearbeiten /etc/dovecot.conf und fügen die Zeile protocols = imap imaps pop3 pop3s hinzu:

vi /etc/dovecot.conf

| [...] # Basisverzeichnis, in dem Laufzeitdaten gespeichert werden. #base_dir = /var/run/dovecot/ # Protokolle, die wir bedienen möchten: # imap imaps pop3 pop3s protocols = imap imaps pop3 pop3s [...] |

Jetzt starten wir Postfix, saslauthd und Dovecot:

chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
chkconfig --levels 235 dovecot on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
/etc/init.d/dovecot start

Um zu sehen, ob SMTP-AUTH und TLS jetzt richtig funktionieren, führen Sie den folgenden Befehl aus:

telnet localhost 25

Nachdem Sie die Verbindung zu Ihrem Postfix-Mailserver hergestellt haben, geben Sie ein

ehlo localhost

Wenn Sie die Zeilen sehen

250-STARTTLS

und

250-AUTH PLAIN LOGIN

ist alles in Ordnung.

[root@server1 ssl]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250 8BITMIME
quit
221 Bye
Connection closed by foreign host.
[root@server1 ssl]#

Geben Sie

quit

ein, um zur Shell des Systems zurückzukehren.

10.1 Maildir

dovecot verwendet das Maildir-Format (nicht mbox), also wenn Sie ISPConfig auf dem Server installieren, stellen Sie bitte sicher, dass Sie Maildir unter Verwaltung -> Server -> Einstellungen -> E-Mail aktivieren. ISPConfig wird dann die notwendige Konfiguration vornehmen.

Wenn Sie ISPConfig nicht installieren möchten, müssen Sie Postfix so konfigurieren, dass E-Mails an das Maildir eines Benutzers zugestellt werden:

postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart

11 Apache2 mit PHP, Ruby, Python

Jetzt installieren wir Apache mit PHP (dies ist PHP 4.3.9; CentOS stellt keine PHP5-Pakete zur Verfügung):

yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel

Dann bearbeiten Sie /etc/httpd/conf/httpd.conf:

vi /etc/httpd/conf/httpd.conf

und ändern Sie DirectoryIndex zu

| [...] DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl [...] |

Jetzt konfigurieren Sie Ihr System, um Apache beim Booten zu starten:

chkconfig --levels 235 httpd on

Starten Sie Apache:

/etc/init.d/httpd start

11.1 PHP global deaktivieren

(Wenn Sie nicht planen, ISPConfig auf diesem Server zu installieren, überspringen Sie bitte diesen Abschnitt!)

In ISPConfig konfigurieren Sie PHP auf Website-Basis, d.h. Sie können angeben, welche Website PHP-Skripte ausführen kann und welche nicht. Dies kann nur funktionieren, wenn PHP global deaktiviert ist, da sonst alle Websites PHP-Skripte ausführen könnten, unabhängig von dem, was Sie in ISPConfig angeben.

Um PHP global zu deaktivieren, bearbeiten wir /etc/httpd/conf.d/php.conf und kommentieren die AddType-Zeile aus:

vi /etc/httpd/conf.d/php.conf

| # # PHP ist eine in HTML eingebettete Skriptsprache, die es Entwicklern erleichtern soll, # dynamisch generierte Webseiten zu schreiben. # LoadModule php4_module modules/libphp4.so # # Veranlasst den PHP-Interpreter, Dateien mit einer .php-Erweiterung zu verarbeiten. # #AddType application/x-httpd-php .php # AddType application/x-httpd-php-source .phps # # Fügen Sie index.php zur Liste der Dateien hinzu, die als Verzeichnisindizes bedient werden. # DirectoryIndex index.php |

Danach starten wir Apache neu:

/etc/init.d/httpd restart

11.2 mod_ruby installieren

Für CentOS 4.8 ist kein mod_ruby-Paket verfügbar, also müssen wir es selbst kompilieren. Zuerst installieren wir einige Voraussetzungen:

yum install httpd-devel ruby ruby-devel

Als nächstes laden wir mod_ruby herunter und installieren es wie folgt:

cd /tmp
wget http://modruby.net/archive/mod_ruby-1.3.0.tar.gz
tar zxvf mod_ruby-1.3.0.tar.gz
cd mod_ruby-1.3.0/
./configure.rb --with-apr-includes=/usr/include/apr-0
make
make install

Schließlich müssen wir das mod_ruby-Modul zur Apache-Konfiguration hinzufügen, also erstellen wir die Datei /etc/httpd/conf.d/ruby.conf…

vi /etc/httpd/conf.d/ruby.conf

| LoadModule ruby_module modules/mod_ruby.so |

… und starten Apache neu:

/etc/init.d/httpd restart

11.3 mod_python installieren

Um mod_python zu installieren, führen wir einfach…

yum install mod_python

… und starten Apache danach neu:

/etc/init.d/httpd restart
Share: X/Twitter LinkedIn

Erhalte neue Beiträge in deinem Posteingang.

Kein Spam. Jederzeit abmelden.