Ubuntu 7.10 (Gutsy Gibbon) Server Installation: LAMP, Email, DNS, FTP, ISPConfig
12 Der DNS Server
Führe dies aus
apt-get install bind9
Aus Sicherheitsgründen wollen wir BIND in einer chroot Umgebung ausführen:
/etc/init.d/bind9 stop
Bearbeite die Datei /etc/default/bind9 so, dass der daemon als unpriviligierter Nutzer bind im Verzeichnis /var/lib/named läuft. Bearbeite die Zeile: OPTIONS=“-u bind“ so OPTIONS=“-u bind -t /var/lib/named“:
vi /etc/default/bind9
OPTIONS="-u bind -t /var/lib/named" # Set RESOLVCONF=no to not run resolvconf RESOLVCONF=yes |
Erstelle die notwendigen Verzeichnisse unter /var/lib:
mkdir -p /var/lib/named/etc
mkdir /var/lib/named/dev
mkdir -p /var/lib/named/var/cache/bind
mkdir -p /var/lib/named/var/run/bind/run
Verschiebe dann das Konfigurationsverzeichnis von /etc zu /var/lib/named/etc:
mv /etc/bind /var/lib/named/etc
Erstelle einen Symlink auf das neue Konfigurationsverzeichnis (um Problemen aus dem Weg zu gehen, wenn bind in Zukunft aktualisiert wird):
ln -s /var/lib/named/etc/bind /etc/bind
Erzeuge Null und random Devices und korrigiere die Berechtigung der Verzeichnisse:
mknod /var/lib/named/dev/null c 1 3
mknod /var/lib/named/dev/random c 1 8
chmod 666 /var/lib/named/dev/null /var/lib/named/dev/random
chown -R bind:bind /var/lib/named/var/*
chown -R bind:bind /var/lib/named/etc/bind
Wir müssen /etc/default/syslogd so bearbeiten, dass weiterhin Systemmeldungen im Sytemlog gespeicher werden. Bearbeite die Zeile: SYSLOGD=““ wie folgt: SYSLOGD=“-a /var/lib/named/dev/log“:
vi /etc/default/syslogd
# # Top configuration file for syslogd # # # Full documentation of possible arguments are found in the manpage # syslogd(8). # # # For remote UDP logging use SYSLOGD="-r" # SYSLOGD="-a /var/lib/named/dev/log" |
Starte den logging daemon neu:
/etc/init.d/sysklogd restart
Starte BIND und überprüfe /var/log/syslog nach Fehlern:
/etc/init.d/bind9 start
13 MySQL
Um MySQL zu installieren, führen wir Folgendes aus
apt-get install mysql-server mysql-client libmysqlclient15-dev
Du wirst gebeten ein Passwort für den MySQL root Benutzer anzulegen – dieses Passwort sowohl für den Nutzer [email protected] gültig als auch für [email protected], also müssen wir das MySQL root Passwort später nicht manuell festlegen (wie das der Fall bei vorherigen Ubuntu Versionen war):
New password for the MySQL „root“ user: <– Dein Root SQL Passwort
Wir möchten, dass MySQL auf allen Netzwerkkarten hört, nicht nur auf dem lokalen Host, daher bearbeiten wir /etc/mysql/my.cnf und kommentieren die Zeile bind-address = 127.0.0.1 aus:
vi /etc/mysql/my.cnf
[...] # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 # [...] |
Dann starten wir MySQL neu:
/etc/init.d/mysql restart
Überprüfe nun dass die Vernetzung aktiviert ist. Führe Folgendes aus
netstat -tap | grep mysql
Die Ausgabe sollte wie folgt aussehen:
[email protected]:~# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 5286/mysqld
[email protected]:~#
14 Postfix mit SMTP-AUTH und TLS
Um Postfix mit SMTP-AUTH und TLS zu installieren, führe folgende Schritte aus:
apt-get install postfix libsasl2-2 sasl2-bin libsasl2-modules libdb3-util procmail
Zwei Fragen werden Dir dann gestellt. Antworte wie folgt:
General type of mail configuration: <– Internet Site
System mail name: <– server1.example.com
Dann führe aus
dpkg-reconfigure postfix
Erneut werden Dir Fragen gestellt:
General type of mail configuration: <– Internet Site
System mail name: <– server1.example.com
Root and postmaster mail recipient: <– [blank]
Other destinations to accept mail for (blank for none): <– server1.example.com, localhost.example.com, localhost.localdomain, localhost
Force synchronous updates on mail queue? <– No
Local networks: <– 127.0.0.0/8
Use procmail for local delivery? <– Yes
Mailbox size limit: <– 0
Local address extension character: <– +
Internet protocols to use: <– all
Als Nächstes führe Folgendes aus:
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.conf
Danach erstellen wir die TLS Zertifikate:
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
Nun konfigurieren wir Postfix für TLS (vergewissere Dich, dass Du den richtigen Hostnamen für myhostname verwendest):
postconf -e ‚myhostname = server1.example.com‘
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 nun so aussehen:
cat /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h # TLS parameters smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_use_tls = yes smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. 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.localdomain, localhost relayhost = mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = 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 smtp_tls_note_starttls_offer = yes 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 |
Starte Postfix neu:
/etc/init.d/postfix restart
Die Authentisierung erfolgt durch saslauthd. Wir müssen ein paar kleine Sachen ändern, damit es gut funktioniert. Da Postfix im Verzeichnis /var/spool/postfix chrooted läuft, müssen wir Folgendes ausführen:
mkdir -p /var/spool/postfix/var/run/saslauthd
Nun müssen wir /etc/default/saslauthd bearbeiten um saslauthd zu aktivieren. Setze START to yes und ändere die Zeile OPTIONS=“-c“ to OPTIONS=“-c -m /var/spool/postfix/var/run/saslauthd -r“:
vi /etc/default/saslauthd
# # Settings for saslauthd daemon # # Should saslauthd run automatically on startup? (default: no) START=yes # Which authentication mechanisms should saslauthd use? (default: pam) # # Available options in this Debian package: # getpwent -- use the getpwent() library function # kerberos5 -- use Kerberos 5 # pam -- use PAM # rimap -- use a remote IMAP server # shadow -- use the local shadow password file # sasldb -- use the local sasldb database file # ldap -- use LDAP (configuration is in /etc/saslauthd.conf) # # Only one option may be used at a time. See the saslauthd man page # for more information. # # Example: MECHANISMS="pam" MECHANISMS="pam" # Additional options for this mechanism. (default: none) # See the saslauthd man page for information about mech-specific options. MECH_OPTIONS="" # How many saslauthd processes should we run? (default: 5) # A value of 0 will fork a new process for each connection. THREADS=5 # Other options (default: -c) # See the saslauthd man page for information about these options. # # Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd" # Note: See /usr/share/doc/sasl2-bin/README.Debian OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" |
Starte nun saslauthd: