GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Il server perfetto - Ubuntu 14.10 (nginx, BIND, Dovecot, ISPConfig 3)

Questo tutorial esiste per queste versioni del sistema operativo

  • Ubuntu 18.04 (castoro bionico)
  • Ubuntu 16.04 (Xenial Xerus)
  • Ubuntu 15.10 (Wyly Werewolf)
  • Ubuntu 15.04 (Vervet vivido)
  • Ubuntu 14.10 (Unicorno utopico)
  • Ubuntu 14.04 LTS (Trusty Tahr)

In questa pagina

  1. Manuale ISPConfig 3
  • 1. Nota preliminare
  • 2. Modifica /etc/apt/sources.list e aggiorna la tua installazione Linux
  • 3. Modifica la shell predefinita
  • 4. Disattiva AppArmor
  • 5. Sincronizza l'orologio di sistema
  • 6. Installa Postfix, Dovecot, MySQL, phpMyAdmin, rkhunter, binutils
  • 7. Installa Amavisd-new, SpamAssassin e Clamav
  • Questo tutorial mostra come preparare un server Ubuntu 14.10 (Utopic Unicorn) (con nginx, BIND, Dovecot) per l'installazione di ISPConfig 3 e come installare ISPConfig 3. ISPConfig 3 è un pannello di controllo di webhosting che consente di configurare quanto segue servizi tramite un browser web:server web Apache o nginx, server di posta Postfix, server Courier o Dovecot IMAP/POP3, server dei nomi MySQL, BIND o MyDNS, PureFTPd, SpamAssassin, ClamAV e molti altri. Questa configurazione copre nginx (anziché Apache), BIND (anziché MyDNS) e Dovecot (anziché Courier).

    Manuale ISPConfig 3

    Per imparare a usare ISPConfig 3, consiglio vivamente di scaricare il Manuale di ISPConfig 3.

    Su più di 300 pagine, copre il concetto alla base di ISPConfig (amministratore, rivenditori, clienti), spiega come installare e aggiornare ISPConfig 3, include un riferimento per tutti i moduli e i campi dei moduli in ISPConfig insieme a esempi di input validi e fornisce tutorial per le attività più comuni in ISPConfig 3. Descrive anche come rendere più sicuro il tuo server e include una sezione per la risoluzione dei problemi alla fine.

    1. Nota preliminare

    In questo tutorial utilizzo l'hostname server1.example.com con l'indirizzo IP 192.168.0.100 e il gateway 192.168.0.1. Queste impostazioni potrebbero differire per te, quindi devi sostituirle dove appropriato. Prima di procedere oltre è necessario disporre di un'installazione minima di base di Ubuntu 14.10 come spiegato nel tutorial.

    2. Modifica /etc/apt/sources.list e aggiorna la tua installazione Linux

    Modifica /etc/apt/sources.list. Commenta o rimuovi il CD di installazione dal file e assicurati che i repository Universe e Multiverse siano abilitati. Dovrebbe assomigliare a questo:

    nano /etc/apt/sources.list
    # 
    
    # deb cdrom:[Ubuntu-Server 14.10 _Utopic Unicorn_ - Release amd64 (20141022.2)]/ utopic main restricted
    
    #deb cdrom:[Ubuntu-Server 14.10 _Utopic Unicorn_ - Release amd64 (20141022.2)]/ utopic main restricted
    
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://de.archive.ubuntu.com/ubuntu/ utopic main restricted
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates main restricted
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team. Also, please note that software in universe WILL NOT receive any
    ## review or updates from the Ubuntu security team.
    deb http://de.archive.ubuntu.com/ubuntu/ utopic universe
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic universe
    deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates universe
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
    ## team, and may not be under a free licence. Please satisfy yourself as to 
    ## your rights to use the software. Also, please note that software in 
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    deb http://de.archive.ubuntu.com/ubuntu/ utopic multiverse
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic multiverse
    deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates multiverse
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://de.archive.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse
    deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse
    
    deb http://security.ubuntu.com/ubuntu utopic-security main restricted
    deb-src http://security.ubuntu.com/ubuntu utopic-security main restricted
    deb http://security.ubuntu.com/ubuntu utopic-security universe
    deb-src http://security.ubuntu.com/ubuntu utopic-security universe
    deb http://security.ubuntu.com/ubuntu utopic-security multiverse
    deb-src http://security.ubuntu.com/ubuntu utopic-security multiverse
    
    ## Uncomment the following two lines to add software from Canonical's
    ## 'partner' repository.
    ## This software is not part of Ubuntu, but is offered by Canonical and the
    ## respective vendors as a service to Ubuntu users.
    # deb http://archive.canonical.com/ubuntu utopic partner
    # deb-src http://archive.canonical.com/ubuntu utopic partner
    
    ## Uncomment the following two lines to add software from Ubuntu's
    ## 'extras' repository.
    ## This software is not part of Ubuntu, but is offered by third-party
    ## developers who want to ship their latest software.
    # deb http://extras.ubuntu.com/ubuntu utopic main
    # deb-src http://extras.ubuntu.com/ubuntu utopic main
    ~                                                        

    Quindi esegui

    apt-get update

    per aggiornare il database del pacchetto apt e

    apt-get upgrade

    per installare gli ultimi aggiornamenti (se presenti). Se vedi che un nuovo kernel viene installato come parte degli aggiornamenti, dovresti riavviare il sistema in seguito:

    reboot

    3. Modifica la shell predefinita

    /bin/sh è un collegamento simbolico a /bin/dash, tuttavia abbiamo bisogno di /bin/bash, non di /bin/dash. Pertanto facciamo questo:

    dpkg-reconfigure dash

    Utilizzare dash come shell di sistema predefinita (/bin/sh)? <-- No

    In caso contrario, l'installazione di ISPConfig avrà esito negativo.

    4. Disattiva AppArmor

    AppArmor è un'estensione di sicurezza (simile a SELinux) che dovrebbe fornire una sicurezza estesa. Non è installato di default a partire dal 13.10. Verificheremo se è installato. Secondo me non è necessario per configurare un sistema sicuro e di solito causa più problemi che vantaggi (pensaci dopo aver fatto una settimana di risoluzione dei problemi perché alcuni servizi non funzionavano come previsto, e quindi scopri che era tutto ok, solo AppArmor stava causando il problema). Pertanto lo disabilito (questo è un must se vuoi installare ISPConfig in un secondo momento).

    Possiamo disabilitarlo in questo modo:

    service apparmor stop
    update-rc.d -f apparmor remove
    apt-get remove apparmor apparmor-utils

    5. Sincronizza l'orologio di sistema

    È una buona idea sincronizzare l'orologio di sistema con un NTP (n rete t ora p rotocol) server su Internet. Esegui semplicemente

    apt-get install ntp ntpdate

    e l'ora del tuo sistema sarà sempre sincronizzata.

    6. Installa Postfix, Dovecot, MySQL, phpMyAdmin, rkhunter, binutils

    Possiamo installare Postfix, Dovecot, MySQL, rkhunter e binutils con un solo comando:

    apt-get install postfix postfix-mysql postfix-doc mariadb-client mariadb-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve sudo

    Ti verranno poste le seguenti domande:

    Nuova password per l'utente "root" MySQL:<-- yourrootsqlpassword
    Ripetere la password per l'utente "root" MySQL:<-- yourrootsqlpassword
    Creare un certificato SSL autofirmato?:<-- Sì
    Nome host:<-- server1.example.com
    Solo locale:<-- OK
    Tipo generale di configurazione della posta:<-- Sito Internet
    Nome della posta di sistema:<- - server1.example.com

    Quindi apri le porte TLS/SSL e di invio in Postfix:

    nano /etc/postfix/master.cf

    Decommenta le sezioni di invio e smtps come segue:aggiungi la riga -o smtpd_client_restrictions=permit_sasl_authenticated, rifiuta entrambe le sezioni e lascia tutto in seguito commentato:

    [...]
    submission inet n       -       -       -       -       smtpd
      -o syslog_name=postfix/submission
      -o smtpd_tls_security_level=encrypt
      -o smtpd_sasl_auth_enable=yes
      -o smtpd_client_restrictions=permit_sasl_authenticated,reject
    #  -o smtpd_reject_unlisted_recipient=no
    #  -o smtpd_client_restrictions=$mua_client_restrictions
    #  -o smtpd_helo_restrictions=$mua_helo_restrictions
    #  -o smtpd_sender_restrictions=$mua_sender_restrictions
    #  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
    #  -o milter_macro_daemon_name=ORIGINATING
    smtps     inet  n       -       -       -       -       smtpd
      -o syslog_name=postfix/smtps
      -o smtpd_tls_wrappermode=yes
      -o smtpd_sasl_auth_enable=yes
      -o smtpd_client_restrictions=permit_sasl_authenticated,reject
    #  -o smtpd_reject_unlisted_recipient=no
    #  -o smtpd_client_restrictions=$mua_client_restrictions
    #  -o smtpd_helo_restrictions=$mua_helo_restrictions
    #  -o smtpd_sender_restrictions=$mua_sender_restrictions
    #  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
    #  -o milter_macro_daemon_name=ORIGINATING
    [...]

    Riavvia Postfix in seguito:

    service postfix restart

    Vogliamo che MySQL ascolti su tutte le interfacce, non solo su localhost, quindi modifichiamo /etc/mysql/my.cnf e commentiamo la riga bind-address =127.0.0.1:

    nano /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
    [...]

    Quindi riavviamo MySQL:

    service mysql restart

    Ora controlla che la rete sia abilitata. Corri

    netstat -tap | grep mysql

    L'output dovrebbe essere simile a questo:

    [email protected]:~# netstat -tap | grep mysql
    tcp        0      0 *:mysql                 *:*                     LISTEN      23785/mysqld    
    [email protected]:~#

    7. Installa Amavisd-new, SpamAssassin e Clamav

    Per installare amavisd-new, SpamAssassin e ClamAV, eseguiamo

    apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl

    La configurazione di ISPConfig 3 utilizza amavisd che carica internamente la libreria dei filtri SpamAssassin, quindi possiamo fermare SpamAssassin per liberare un po' di RAM:

    service spamassassin stop
    update-rc.d -f spamassassin remove

    Per eseguire clamav usa

    freshclam
    service clamav-daemon start

    Ubuntu
    1. Il server perfetto - Ubuntu 14.04 (nginx, BIND, MySQL, PHP, Postfix, Dovecot e ISPConfig 3)

    2. Il server perfetto - Ubuntu 15.04 (nginx, BIND, Dovecot e ISPConfig 3)

    3. Il server perfetto - Ubuntu 15.10 (nginx, MySQL, PHP, Postfix, BIND, Dovecot, Pure-FTPD e ISPConfig 3)

    4. Il server perfetto - Ubuntu 16.04 (Nginx, MySQL, PHP, Postfix, BIND, Dovecot, Pure-FTPD e ISPConfig 3.1)

    5. Il server perfetto - Ubuntu 18.04 (Nginx, MySQL, PHP, Postfix, BIND, Dovecot, Pure-FTPD e ISPConfig 3.1)

    Il server perfetto - Ubuntu 11.10 con Nginx [ISPConfig 3]

    Il server perfetto - Ubuntu 12.04 LTS (Apache2, BIND, Dovecot, ISPConfig 3)

    Il server perfetto - Ubuntu 12.10 (Apache2, BIND, Dovecot, ISPConfig 3)

    Il server perfetto - OpenSUSE 12.2 x86_64 (nginx, Dovecot, ISPConfig 3)

    Il server perfetto - Debian Wheezy (nginx, BIND, Dovecot, ISPConfig 3)

    Il server perfetto - Ubuntu 13.04 (Apache2, BIND, Dovecot, ISPConfig 3)