GNU/Linux >> Linux Esercitazione >  >> Panels >> Panels

Il server perfetto - Ubuntu 11.04 [ISPConfig 3]

Il server perfetto - Ubuntu 11.04 [ISPConfig 3]

Questo tutorial mostra come preparare un server Ubuntu 11.04 (Natty Narwhal) per l'installazione di ISPConfig 3 e come installare ISPConfig 3. ISPConfig 3 è un pannello di controllo di webhosting che consente di configurare i seguenti servizi tramite un browser web:Apache web server, server di posta Postfix, server dei nomi MySQL, BIND o MyDNS, PureFTPd, SpamAssassin, ClamAV e molti altri.

Tieni presente che questa configurazione non funziona per ISPConfig 2 ! È valido solo per ISPConfig 3!

Non garantisco che questo funzionerà per te!

Manuale ISPConfig 3

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

Su circa 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.

App ISPConfig Monitor per Android

Con l'app ISPConfig Monitor, puoi controllare lo stato del tuo server e scoprire se tutti i servizi funzionano come previsto. Puoi controllare le porte TCP e UDP ed eseguire il ping dei tuoi server. In aggiunta a ciò, puoi utilizzare questa app per richiedere dettagli dai server su cui è installato ISPConfig (tieni presente che la versione minima di ISPConfig 3 installata con supporto per l'app ISPConfig Monitor è 3.0.3.3! ); questi dettagli includono tutto ciò che sai dal modulo Monitor nel pannello di controllo di ISPConfig (ad es. servizi, log di posta e di sistema, coda di posta, informazioni su CPU e memoria, utilizzo del disco, quota, dettagli del sistema operativo, registro RKHunter, ecc.) e ovviamente , poiché ISPConfig è compatibile con più server, puoi controllare tutti i server controllati dal tuo server principale ISPConfig.

Per le istruzioni di download e utilizzo, visitare http://www.ispconfig.org/ispconfig-3/ispconfig-monitor-app-for-android/.

1 Requisiti

Per installare un tale sistema avrai bisogno di quanto segue:

  • il CD del server Ubuntu 11.04, disponibile qui:http://releases.ubuntu.com/releases/11.04/ubuntu-11.04-server-i386.iso (i386) o http://releases.ubuntu.com/releases /11.04/ubuntu-11.04-server-amd64.iso (x86_64)
  • una connessione Internet veloce.

2 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.

3 Il sistema base

Inserisci il tuo CD di installazione di Ubuntu nel tuo sistema e avvia da esso. Seleziona la tua lingua:

Quindi seleziona Installa Ubuntu Server:

Scegli di nuovo la tua lingua (?):

Quindi seleziona la tua posizione:

Se hai selezionato una combinazione insolita di lingua e posizione (come l'inglese come lingua e la Germania come posizione, come nel mio caso), il programma di installazione potrebbe dirti che non esiste una locale definita per questa combinazione; in questo caso devi selezionare la locale manualmente. Seleziono en_US.UTF-8 qui:

Scegli un layout di tastiera (ti verrà chiesto di premere alcuni tasti e il programma di installazione proverà a rilevare il layout di tastiera in base ai tasti premuti):

Il programma di installazione controlla il CD di installazione, l'hardware e configura la rete con DHCP se è presente un server DHCP nella rete:

Il server perfetto - Ubuntu 11.04 [ISPConfig 3] - Pagina 2

Immettere il nome host. In questo esempio, il mio sistema si chiama server1.example.com , quindi inserisco server1 :

Si prega di verificare se l'installatore ha rilevato correttamente il fuso orario. In tal caso, seleziona Sì, altrimenti No:

Ora devi partizionare il tuo disco rigido. Per semplicità seleziono Guidato - usa l'intero disco e configura LVM - questo creerà un gruppo di volumi con due volumi logici, uno per il file system / e un altro per lo scambio (ovviamente, il partizionamento dipende totalmente da te - se sai cosa stai facendo, puoi anche configurare le tue partizioni manualmente).

Seleziona il disco che vuoi partizionare:

Quando ti viene chiesto Scrivi le modifiche sui dischi e configura LVM?, seleziona Sì:

Se hai selezionato Guidato - usa l'intero disco e imposta LVM, il partizionatore creerà un grande gruppo di volumi che utilizza tutto lo spazio su disco. È ora possibile specificare la quantità di spazio su disco che deve essere utilizzata dai volumi logici per / e swap. Ha senso lasciare un po' di spazio inutilizzato in modo da poter espandere in seguito i volumi logici esistenti o crearne di nuovi:questo ti dà maggiore flessibilità.

Al termine, premi Sì quando ti viene chiesto Scrivi le modifiche sui dischi?:

Successivamente, le tue nuove partizioni vengono create e formattate:

Ora è in corso l'installazione del sistema di base:

Crea un utente, ad esempio l'utente Amministratore con il nome utente amministratore (non utilizzare il nome utente admin in quanto è un nome riservato su Ubuntu 11.04):

Non ho bisogno di una directory privata crittografata, quindi scelgo No qui:

Successivamente viene configurato il gestore di pacchetti apt. Lascia vuota la riga del proxy HTTP a meno che tu non stia utilizzando un server proxy per la connessione a Internet:

Sono un po' vecchio stile e mi piace aggiornare manualmente i miei server per avere un maggiore controllo, quindi seleziono Nessun aggiornamento automatico. Naturalmente, sta a te scegliere cosa selezionare qui:

Abbiamo bisogno di un server DNS, di posta e LAMP, ma tuttavia non ne seleziono nessuno ora perché mi piace avere il pieno controllo su ciò che viene installato sul mio sistema. Installeremo i pacchetti necessari manualmente in seguito. L'unico elemento che seleziono qui è il server OpenSSH in modo da potermi collegare immediatamente al sistema con un client SSH come PuTTY al termine dell'installazione:

L'installazione continua:

Viene installato il boot loader GRUB:

Seleziona Sì quando ti viene chiesto Installa il caricatore di avvio GRUB nel record di avvio principale?:

L'installazione del sistema di base è ora terminata. Rimuovere il CD di installazione dall'unità CD e premere Continua per riavviare il sistema:

Al passaggio successivo...

Il server perfetto - Ubuntu 11.04 [ISPConfig 3] - Pagina 3

4 Ottieni i privilegi di root

Dopo il riavvio è possibile effettuare il login con il nome utente creato in precedenza (es. amministratore). Poiché dobbiamo eseguire tutti i passaggi di questo tutorial con i privilegi di root, possiamo anteporre tutti i comandi in questo tutorial con la stringa sudo, oppure diventare root in questo momento digitando

sudo su

(Puoi anche abilitare il login di root eseguendo

sudo passwd root

e dando una password a root. Puoi quindi accedere direttamente come root, ma questo è disapprovato dagli sviluppatori e dalla comunità di Ubuntu per vari motivi. Vedi http://ubuntuforums.org/showthread.php?t=765414.)

5 Installa il server SSH (opzionale)

Se non hai installato il server OpenSSH durante l'installazione del sistema, puoi farlo ora:

apt-get install ssh openssh-server

D'ora in poi puoi utilizzare un client SSH come PuTTY e connetterti dalla tua workstation al tuo server Ubuntu 11.04 e seguire i passaggi rimanenti di questo tutorial.

6 Installa vim-nox (opzionale)

Userò vi come editor di testo in questo tutorial. Il programma vi predefinito ha uno strano comportamento su Ubuntu e Debian; per risolvere questo problema, installiamo vim-nox:

apt-get install vim-nox

(Non devi farlo se usi un editor di testo diverso come joe o nano.)

7 Configura la rete

Poiché il programma di installazione di Ubuntu ha configurato il nostro sistema per ottenere le sue impostazioni di rete tramite DHCP, dobbiamo cambiarlo ora perché un server dovrebbe avere un indirizzo IP statico. Modifica /etc/network/interfaces e adattarlo alle tue esigenze (in questa configurazione di esempio userò l'indirizzo IP 192.168.0.100 ):

vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

Quindi riavvia la rete:

/etc/init.d/networking restart

Quindi modifica /etc/hosts. Rendilo simile a questo:

vi /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.0.100   server1.example.com     server1

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Ora corri

echo server1.example.com > /etc/hostname
/etc/init.d/hostname restart

Successivamente, corri

hostname
hostname -f

Entrambi dovrebbero mostrare server1.example.com ora.

8 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:

vi /etc/apt/sources.list
#

# deb cdrom:[Ubuntu-Server 11.04 _Natty Narwhal_ - Release amd64 (20110426)]/ natty main restricted

#deb cdrom:[Ubuntu-Server 11.04 _Natty Narwhal_ - Release amd64 (20110426)]/ natty 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/ natty main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ natty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ natty-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ natty-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/ natty universe
deb-src http://de.archive.ubuntu.com/ubuntu/ natty universe
deb http://de.archive.ubuntu.com/ubuntu/ natty-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ natty-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/ natty multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ natty multiverse
deb http://de.archive.ubuntu.com/ubuntu/ natty-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ natty-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## 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/ natty-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu natty-security main restricted
deb-src http://security.ubuntu.com/ubuntu natty-security main restricted
deb http://security.ubuntu.com/ubuntu natty-security universe
deb-src http://security.ubuntu.com/ubuntu natty-security universe
deb http://security.ubuntu.com/ubuntu natty-security multiverse
deb-src http://security.ubuntu.com/ubuntu natty-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 natty partner
# deb-src http://archive.canonical.com/ubuntu natty 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 natty main
# deb-src http://extras.ubuntu.com/ubuntu natty 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

9 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.

10 Disattiva AppArmor

AppArmor è un'estensione di sicurezza (simile a SELinux) che dovrebbe fornire una sicurezza estesa. 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:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

11 Sincronizzare 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.

Il server perfetto - Ubuntu 11.04 [ISPConfig 3] - Pagina 4

12 Installa Postfix, Courier, Saslauthd, MySQL, rkhunter, binutils

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

apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl getmail4 rkhunter binutils maildrop

Ti verranno poste le seguenti domande:

Nuova password per l'utente "root" di MySQL:<-- yourrootsqlpassword
Ripeti la password per l'utente "root" di MySQL:<-- yourrootsqlpassword
Tipo generale di configurazione della posta:<-- Sito Internet
Nome e-mail di sistema:<-- server1.example.com
Creare directory per l'amministrazione basata sul Web? <-- Nessun
certificato SSL richiesto <-- Ok

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:

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

Quindi riavviamo MySQL:

/etc/init.d/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      9990/mysqld
[email protected]:~#

Durante l'installazione, i certificati SSL per IMAP-SSL e POP3-SSL vengono creati con il nome host localhost. Per cambiarlo nel nome host corretto (server1.example.com in questo tutorial), elimina i certificati...

cd /etc/courier
rm -f /etc/courier/imapd.pem
rm -f /etc/courier/pop3d.pem

... e modificare i due file seguenti; sostituisci CN=localhost con CN=server1.example.com (puoi anche modificare gli altri valori, se necessario):

vi /etc/courier/imapd.cnf
[...]
CN=server1.example.com
[...]
vi /etc/courier/pop3d.cnf
[...]
CN=server1.example.com
[...]

Quindi ricrea i certificati...

mkimapdcert
mkpop3dcert

... e riavvia Courier-IMAP-SSL e Courier-POP3-SSL:

/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop-ssl restart

13 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:

/etc/init.d/spamassassin stop
update-rc.d -f spamassassin remove

14 Installa Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear e mcrypt

Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear e mcrypt possono essere installati come segue:

apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libruby libapache2-mod-ruby

Vedrai la seguente domanda:

Server Web da riconfigurare automaticamente:<-- apache2
Configurare il database per phpmyadmin con dbconfig-common? <-- No

Quindi eseguire il comando seguente per abilitare i moduli Apache suexec, rewrite, ssl, actions e include (più dav, dav_fs e auth_digest se si desidera utilizzare WebDAV):

a2enmod suexec rewrite ssl actions include
a2enmod dav_fs dav auth_digest

Riavvia Apache in seguito:

/etc/init.d/apache2 restart

Se vuoi ospitare file Ruby con estensione .rb sui tuoi siti web creati tramite ISPConfig, devi commentare la riga application/x-ruby rb in /etc/mime.types:

vi /etc/mime.types
[...]
#application/x-ruby                             rb
[...]

(Questo è necessario solo per i file .rb; i file Ruby con estensione .rbx funzionano immediatamente.)

Riavvia Apache in seguito:

/etc/init.d/apache2 restart

15 Installa PureFTPd e Quota

PureFTPd e quota possono essere installati con il seguente comando:

apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool

Modifica il file /etc/default/pure-ftpd-common...

vi /etc/default/pure-ftpd-common

... e assicurati che la modalità di avvio sia impostata su standalone e imposta VIRTUALCHROOT=true:

[...]
STANDALONE_OR_INETD=standalone
[...]
VIRTUALCHROOT=true
[...]

Ora configuriamo PureFTPd per consentire sessioni FTP e TLS. FTP è un protocollo molto insicuro perché tutte le password e tutti i dati vengono trasferiti in chiaro. Utilizzando TLS, l'intera comunicazione può essere crittografata, rendendo così l'FTP molto più sicuro.

Se vuoi consentire sessioni FTP e TLS, esegui

echo 1 > /etc/pure-ftpd/conf/TLS

Per utilizzare TLS, dobbiamo creare un certificato SSL. Lo creo in /etc/ssl/private/, quindi creo prima quella directory:

mkdir -p /etc/ssl/private/

Successivamente, possiamo generare il certificato SSL come segue:

openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem

Nome del Paese (codice di 2 lettere) [AU]:<-- Inserisci il nome del tuo Paese (ad es. "DE").
Nome Stato o Provincia (nome completo) [Stato-Stato]:<-- Inserisci il tuo Stato o nome della provincia.
Nome località (ad es. città) []:<-- Inserisci la tua città.
Nome organizzazione (ad es. azienda) [Internet Widgits Pty Ltd]:<-- Inserisci il nome dell'organizzazione (ad es. il nome della tua azienda).
Nome dell'unità organizzativa (ad es. sezione) []:<-- Inserisci il nome dell'unità organizzativa (ad es. "Dipartimento IT").
Nome comune (ad es. IL TUO nome) []:<-- Inserisci il nome di dominio completo del sistema (ad es. "server1.example.com").
Indirizzo e-mail []:<-- Inserisci il tuo indirizzo e-mail.

Modifica le autorizzazioni del certificato SSL:

chmod 600 /etc/ssl/private/pure-ftpd.pem

Quindi riavvia PureFTPd:

/etc/init.d/pure-ftpd-mysql restart

Modifica /etc/fstab. Il mio è simile a questo (ho aggiunto ,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 alla partizione con il punto di montaggio /):

vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/server1-root /               ext4    errors=remount-ro,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0       1
# /boot was on /dev/sda1 during installation
UUID=deae7cd1-b106-47aa-9a7c-512f046d2ebf /boot           ext2    defaults        0       2
/dev/mapper/server1-swap_1 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

Per abilitare la quota, esegui questi comandi:

mount -o remount /
quotacheck -avugm
quotaon -avug

16 Installa il server DNS BIND

BIND può essere installato come segue:

apt-get install bind9 dnsutils

17 Installa Vlogger, Webalizer e AWstats

Vlogger, webalizer e AWstats possono essere installati come segue:

apt-get install vlogger webalizer awstats geoip-database

Apri /etc/cron.d/awstats in seguito...

vi /etc/cron.d/awstats

... e commenta entrambi i lavori cron in quel file:

#*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh

# Generate static reports:
#10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh

18 Installa Jailkit

Jailkit è necessario solo se si desidera eseguire il chroot degli utenti SSH. Può essere installato come segue (importante:Jailkit deve essere installato prima di ISPConfig - non può essere installato in seguito!):

apt-get install build-essential autoconf automake1.9 libtool flex bison debhelper
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.14.tar.gz
tar xvfz jailkit-2.14.tar.gz
cd jailkit-2.14
./debian/rules binary
cd ..
dpkg -i jailkit_2.14-1_*.deb
rm -rf jailkit-2.14*

Il server perfetto - Ubuntu 11.04 [ISPConfig 3] - Pagina 5

19 Installa fail2ban

Questo è facoltativo ma consigliato, perché il monitor ISPConfig tenta di mostrare il registro fail2ban:

apt-get install fail2ban

Per fare in modo che fail2ban controlli PureFTPd, SASL e Courier, crea il file /etc/fail2ban/jail.local:

vi /etc/fail2ban/jail.local
[pureftpd]

enabled  = true
port     = ftp
filter   = pureftpd
logpath  = /var/log/syslog
maxretry = 3


[sasl]

enabled  = true
port     = smtp
filter   = sasl
logpath  = /var/log/mail.log
maxretry = 5


[courierpop3]

enabled  = true
port     = pop3
filter   = courierpop3
logpath  = /var/log/mail.log
maxretry = 5


[courierpop3s]

enabled  = true
port     = pop3s
filter   = courierpop3s
logpath  = /var/log/mail.log
maxretry = 5


[courierimap]

enabled  = true
port     = imap2
filter   = courierimap
logpath  = /var/log/mail.log
maxretry = 5


[courierimaps]

enabled  = true
port     = imaps
filter   = courierimaps
logpath  = /var/log/mail.log
maxretry = 5

Quindi crea i seguenti cinque file di filtro:

vi /etc/fail2ban/filter.d/pureftpd.conf
[Definition]
failregex = .*pure-ftpd: \(.*@<HOST>\) \[WARNING\] Authentication failed for user.*
ignoreregex =
vi /etc/fail2ban/filter.d/courierpop3.conf
# Fail2Ban configuration file
#
# $Revision: 100 $
#

[Definition]

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#
failregex = pop3d: LOGIN FAILED.*ip=\[.*:<HOST>\]

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
vi /etc/fail2ban/filter.d/courierpop3s.conf
# Fail2Ban configuration file
#
# $Revision: 100 $
#

[Definition]

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#
failregex = pop3d-ssl: LOGIN FAILED.*ip=\[.*:<HOST>\]

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
vi /etc/fail2ban/filter.d/courierimap.conf
# Fail2Ban configuration file
#
# $Revision: 100 $
#

[Definition]

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#
failregex = imapd: LOGIN FAILED.*ip=\[.*:<HOST>\]

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
vi /etc/fail2ban/filter.d/courierimaps.conf
# Fail2Ban configuration file
#
# $Revision: 100 $
#

[Definition]

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#
failregex = imapd-ssl: LOGIN FAILED.*ip=\[.*:<HOST>\]

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =

Riavvia fail2ban in seguito:

/etc/init.d/fail2ban restart

20 Installa SquirrelMail

Per installare il client webmail di SquirrelMail, esegui

apt-get install squirrelmail

Quindi crea il seguente collegamento simbolico...

ln -s /usr/share/squirrelmail/ /var/www/webmail

... e configura SquirrelMail:

squirrelmail-configure

Dobbiamo dire a SquirrelMail che stiamo usando Courier-IMAP/-POP3:

Configurazione di SquirrelMail: Leggi: config.php (1.4.0)
---------------------------------- ------------------------
Menu principale --
1.  Preferenze organizzazione
2.  Impostazioni server
3.  Default cartella
4.  Opzioni generali
5.  Temi
6.  Rubriche 
7.  Messaggio del giorno (MOTD)
8.  Plugin
9.  Database
10. Lingue

D.  Imposta impostazioni predefinite per server IMAP specifici

C   Attiva colore
S   Salva data
Q   Esci

Comando >> <-- D


Configurazione SquirrelMail : Leggi: config.php
---- -------------------------------------------------- ---
Mentre stiamo creando SquirrelMail, abbiamo scoperto alcune
preferenze che funzionano meglio con alcuni server che non funzionano quindi
bene con altri. Se seleziona il server IMAP, questa opzione 
imposterà alcune impostazioni predefinite per quel server.

Tieni presente che dovrai sempre andare attraverso e assicurarti
tutto è corretto. Questo non cambia tutto. Ci sono
solo alcune impostazioni che verranno modificate.

Seleziona il tuo server IMAP:
    bincimap    =server Bincimap IMAP
    courier     = server IMAP Courier
    cyrus       = Cyrus IMAP server
    dovecot     = Dovecot Secure IMAP server
    exchange    = Microsoft Exchange IMAP server
    hmailserver = hMailServer
    macosx      = Mac OS X Mailserver
    mercury32   = Mercury /32
    uw         ==server IMAP dell'Università di Washington
    gmail       =accesso IMAP agli account di posta di Google (Gmail)

   chiudi        = Non cambiare nulla
Comando >> <-- corriere


Configurazione di SquirrelMail : Leggi: config.php
----------------------- ----------------------------------
Mentre abbiamo costruito SquirrelMail, ne abbiamo scoperto alcuni
preferenze che funzionano meglio con alcuni server che non funzionano quindi
bene con altri. Se seleziona il server IMAP, questa opzione 
imposterà alcune impostazioni predefinite per quel server.

Tieni presente che dovrai sempre andare attraverso e assicurarti
tutto è corretto. Questo non cambia tutto. Ci sono
solo alcune impostazioni che verranno modificate.

Seleziona il tuo server IMAP:
    bincimap    =server Bincimap IMAP
    courier     = server IMAP Courier
    cyrus       = Cyrus IMAP server
    dovecot     = Dovecot Secure IMAP server
    exchange    = Microsoft Exchange IMAP server
    hmailserver = hMailServer
    macosx      = Mac OS X Mailserver
    mercury32   = Mercury /32
    uw         ==server IMAP dell'Università di Washington

    chiudi        = Non cambiare nulla
Comando >> corriere

             imap_server_type = corriere
Default_Folder_prefix =Inbox.
Trash_Folder =Trash
Sent_Folder =SENT
Draft_Folder =Draft
show_prefix_option =false
default_sub_of_inbox =false
show_contain_subrers_option =false delimitatore_facoltativo = .
                delete_folder = true

Premi qualsiasi tasto per continuare... <-- ENTER


Configurazione SquirrelMail : Leggi: config.php ( 1.4.0)
------------------------------------------- ---------------
Menu principale --
1.  Preferenze organizzazione
2.  Impostazioni server
3.  Default cartella
4.  Opzioni generali
5.  Temi
6.  Rubriche di indirizzi
7.  Messaggio del giorno (MOTD)
8.  Plugin
9.  Database
10. Lingue

D.  Imposta impostazioni predefinite per server IMAP specifici

C   Attiva colore
S   Salva dati
Q   Esci

Comando >> <-- S


Configurazione di SquirrelMail : Leggi: config.php (1.4.0)
-------- --------------------------------------------------
Menu principale --
1.  Preferenze organizzazione
2.  Impostazioni del server
3.  Default cartella
4.  Opzioni generali
5.  Temi
6.  Rubriche di indirizzi
7.  Messaggio di the Day (MOTD)
8.  Plugin
9.  Database
10. Lingue

D.  Imposta impostazioni predefinite per server IMAP specifici

C   Attiva colore
S   Salva dati
Q   Esci

Comando >> S

Dati salvati in config.php
Premi invio per continuare... <-- INVIO


Configurazione di SquirrelMail : Leggi: config.php (1.4.0)
---------- ------------------------------------------------
Menu principale --
1.  Preferenze organizzazione
2.  Impostazioni server
3.  Default cartella
4.  Opzioni generali
5.  Temi
6. Rubriche
7.  Messaggio del giorno (MOTD)
8.  Plugin
9.  Database
10. Lingue

D.  Imposta predefinita impostazioni per server IMAP specifici

C   Attiva colore
S   Salva dati
Q   Esci

Comando >> <-- Q

Successivamente puoi accedere a SquirrelMail da http://server1.example.com/webmail o http://192.168.0.100/webmail:

Il server perfetto - Ubuntu 11.04 [ISPConfig 3] - Pagina 6

21 Installa ISPConfig 3

Per installare ISPConfig 3 dall'ultima versione rilasciata, procedere come segue:

cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/

Il prossimo passo è eseguire

php -q install.php

Questo avvierà il programma di installazione di ISPConfig 3. Il programma di installazione configurerà per te tutti i servizi come Postfix, SASL, Courier, ecc. Non è necessaria una configurazione manuale come richiesto per ISPConfig 2 (guide di configurazione perfette).

[email protected]:/tmp/ispconfig3_install/install# php -q install.php


------------------- -------------------------------------------------- -----------
 _____ ___________   _____             __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | | `--. \  __/  | | / _ \| '_ \| _| |/ _` | |_ |
 _| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|     \____/\___/|_| |_|_| | \____/
                                                                                 __/ |
                                           |___/
-------------------------------------- -------------------------------------------


>> Configurazione iniziale

Sistema operativo: Debian 6.0 (Squeeze/Sid) o compatibile

    Di seguito saranno alcune domande per la configurazione primaria quindi fai attenzione.
    I valori predefiniti sono tra [parentesi tra parentesi] e possono essere accettati con .
    Tocca "chiudi" (senza virgolette) per interrompere l'installazione.


Seleziona lingua (en,de) [en]: <-- ENTER

Modalità installazione (standard, esperto) [standard]: <-- ENTER

Nome host completo qualificato ( FQDN) del server, es server1.domain.tld  [server1.example.com]: <-- ENTER

Nome host del server MySQL [localhost]: <-- ENTER

Nome utente root di MySQL [root]: <-- ENTER

Password root MySQL []: <-- yourrootsqlpassword

Database MySQL per creare [dbispconfig]: <-- ENTER

MySQL charset [utf8]: <-- ENTER

Generazione di una chiave privata RSA a 2048 bit
....+++
..+++
scrittura di una nuova chiave privata su 'smtpd.key'
-----
Ti verrà chiesto di inserire le informazioni che verranno incorporate nella richiesta di certificato. un DN.
Ci sono alcuni campi ma puoi lasciarne alcuni vuoti .
-----
Nome del paese (codice di 2 lettere) [AU]: <-- ENTER
Nome dello stato o della provincia (nome completo) [Stato-alcuno]: <-- ENTER
Nome della località (ad es. città) []: <-- ENTER
Nome dell'organizzazione (ad es. azienda) [Internet Widgits Pty Ltd]: <-- ENTER
Nome dell'unità organizzativa (ad es. , sezione) []: <-- ENTER
Nome comune (ad es. IL TUO nome) []: <-- ENTER
Email Address []: <-- ENTER
Configuring Jailkit
Configuring SASL
Configuring PAM
Configuring Courier
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring Pureftpd
Configuring BIND
Configuring Apache
Configuring Vlogger
Configuring Apps vhost
Configuring Firewall
Installing ISPConfig
ISPConfig Port [8080]: <-- ENTER

Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Restarting services ...
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql stop/waiting
mysql start/running, process 27585
 * Stopping Postfix Mail Transport Agent postfix
   ...done.
 * Starting Postfix Mail Transport Agent postfix
   ...done.
 * Stopping SASL Authentication Daemon saslauthd
   ...done.
 * Starting SASL Authentication Daemon saslauthd
   ...done.
Stopping amavisd: amavisd-new.
Starting amavisd: amavisd-new.
 * Stopping ClamAV daemon clamd
   ...done.
 * Starting ClamAV daemon clamd
   ...done.
 * Stopping Courier authentication services authdaemond
   ...done.
 * Starting Courier authentication services authdaemond
   ...done.
 * Stopping Courier IMAP server imapd
   ...done.
 * Starting Courier IMAP server imapd
   ...done.
 * Stopping Courier IMAP-SSL server imapd-ssl
   ...done.
 * Starting Courier IMAP-SSL server imapd-ssl
   ...done.
 * Stopping Courier POP3 server...
   ...done.
 * Starting Courier POP3 server...
   ...done.
 * Stopping Courier POP3-SSL server...
   ...done.
 * Starting Courier POP3-SSL server...
   ...done.
 * Restarting web server apache2
 ... waiting . ...done.
Restarting ftp server: Running: /usr/sbin/pure-ftpd-mysql-virtualchroot -l mysql:/etc/pure-ftpd/db/mysql.conf -l pam -E -Y 1 -8 UTF-8 -H -A -O clf:/var/log/pure-ftpd/transfer.log -D -b -u 1000 -B
Installation completed.
[email protected]:/tmp/ispconfig3_install/install#

The installer automatically configures all underlying services, so no manual configuration is needed.

Afterwards you can access ISPConfig 3 under http://server1.example.com:8080/ or http://192.168.0.100:8080/. Log in with the username admin and the password admin (you should change the default password after your first login):

The system is now ready to be used.

21.1 ISPConfig 3 Manual

In order to learn how to use ISPConfig 3, I strongly recommend to download the ISPConfig 3 Manual.

On about 300 pages, it covers the concept behind ISPConfig (admin, resellers, clients), explains how to install and update ISPConfig 3, includes a reference for all forms and form fields in ISPConfig together with examples of valid inputs, and provides tutorials for the most common tasks in ISPConfig 3. It also lines out how to make your server more secure and comes with a troubleshooting section at the end.

21.2 ISPConfig Monitor App For Android

With the ISPConfig Monitor App, you can check your server status and find out if all services are running as expected. You can check TCP and UDP ports and ping your servers. In addition to that you can use this app to request details from servers that have ISPConfig installed (please note that the minimum installed ISPConfig 3 version with support for the ISPConfig Monitor App is 3.0.3.3! ); these details include everything you know from the Monitor module in the ISPConfig Control Panel (e.g. services, mail and system logs, mail queue, CPU and memory info, disk usage, quota, OS details, RKHunter log, etc.), and of course, as ISPConfig is multiserver-capable, you can check all servers that are controlled from your ISPConfig master server.

For download and usage instructions, please visit http://www.ispconfig.org/ispconfig-3/ispconfig-monitor-app-for-android/.

22 Additional Notes

22.1 OpenVZ

If the Ubuntu server that you've just set up in this tutorial is an OpenVZ container (virtual machine), you should do this on the host system (I'm assuming that the ID of the OpenVZ container is 101 - replace it with the correct VPSID on your system):

VPSID=101
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE
do
  vzctl set $VPSID --capability ${CAP}:on --save
done

22.2 SquirrelMail

Lots of people have reported problems (such as getting 404 Not Found errors) using the SquirrelMail webmail package in their web sites created through ISPConfig 3. This guide explains how to configure SquirrelMail on an Ubuntu 11.04 server so that you can use it from within your web sites (created through ISPConfig).

SquirrelMail's Apache configuration is in the file /etc/squirrelmail/apache.conf, but this file isn't loaded by Apache because it is not in the /etc/apache2/conf.d/ directory. Therefore we create a symlink called squirrelmail.conf in the /etc/apache2/conf.d/ directory that points to /etc/squirrelmail/apache.conf and reload Apache afterwards:

cd /etc/apache2/conf.d/
ln -s ../../squirrelmail/apache.conf squirrelmail.conf
/etc/init.d/apache2 reload

Now open /etc/apache2/conf.d/squirrelmail.conf...

vi /etc/apache2/conf.d/squirrelmail.conf

... and add the following lines to the container that make sure that mod_php is used for accessing SquirrelMail, regardless of what PHP mode you select for your website in ISPConfig:

[...]
<Directory /usr/share/squirrelmail>
  Options FollowSymLinks
  <IfModule mod_php5.c>
    AddType application/x-httpd-php .php
    php_flag magic_quotes_gpc Off
    php_flag track_vars On
    php_admin_flag allow_url_fopen Off
    php_value include_path .
    php_admin_value upload_tmp_dir /var/lib/squirrelmail/tmp
    php_admin_value open_basedir /usr/share/squirrelmail:/etc/squirrelmail:/var/lib/squirrelmail:/etc/hostname:/etc/mailname:/var/spool/squirrelmail
    php_flag register_globals off
  </IfModule>
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
  # access to configtest is limited by default to prevent information leak
  <Files configtest.php>
    order deny,allow
    deny from all
    allow from 127.0.0.1
  </Files>
</Directory>
[...]

Create the directory /var/lib/squirrelmail/tmp...

mkdir /var/lib/squirrelmail/tmp

... and make it owned by the user www-data:

chown www-data /var/lib/squirrelmail/tmp

Reload Apache again:

/etc/init.d/apache2 reload

That's it already - /etc/apache2/conf.d/squirrelmail.conf defines an alias called /squirrelmail that points to SquirrelMail's installation directory /usr/share/squirrelmail.

You can now access SquirrelMail from your web site as follows:

http://www.example.com/squirrelmail

You can also access it from the ISPConfig control panel vhost as follows (this doesn't need any configuration in ISPConfig):

http://server1.example.com:8080/squirrelmail

If you'd like to use the alias /webmail instead of /squirrelmail, simply open /etc/apache2/conf.d/squirrelmail.conf...

vi /etc/apache2/conf.d/squirrelmail.conf

... and add the line Alias /webmail /usr/share/squirrelmail:

Alias /squirrelmail /usr/share/squirrelmail
Alias /webmail /usr/share/squirrelmail
[...]

Then reload Apache:

/etc/init.d/apache2 reload

Now you can access Squirrelmail as follows:

http://www.example.com/webmail
http://server1.example.com:8080/webmail

If you'd like to define a vhost like webmail.example.com where your users can access SquirrelMail, you'd have to add the following vhost configuration to /etc/apache2/conf.d/squirrelmail.conf:

vi /etc/apache2/conf.d/squirrelmail.conf
[...]
<VirtualHost 1.2.3.4:80>
  DocumentRoot /usr/share/squirrelmail
  ServerName webmail.example.com
</VirtualHost>

Make sure you replace 1.2.3.4 with the correct IP address of your server. Of course, there must be a DNS record for webmail.example.com that points to the IP address that you use in the vhost configuration. Also make sure that the vhost webmail.example.com does not exist in ISPConfig (otherwise both vhosts will interfere with each other!).

Now reload Apache...

/etc/init.d/apache2 reload

... and you can access SquirrelMail under http://webmail.example.com!

  • Ubuntu:http://www.ubuntu.com/
  • Configurazione ISP:http://www.ispconfig.org/

Panels
  1. Come aggiornare un server Ubuntu 7.10 ("The Perfect Setup" + ISPConfig) a Ubuntu 8.04 LTS

  2. Come aggiornare un server Ubuntu 7.04 ("The Perfect Setup" + ISPConfig) a Ubuntu 7.10

  3. Il server perfetto - Fedora 15 x86_64 [ISPConfig 2]

  4. Il server perfetto - Fedora 15 x86_64 [ISPConfig 3]

  5. Il server perfetto - Ubuntu Natty Narwhal (Ubuntu 11.04) [ISPConfig 2]

Il server perfetto - CentOS 6.0 x86_64 [ISPConfig 2]

Il server perfetto - CentOS 6.0 x86_64 [ISPConfig 3]

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

Il server perfetto - CentOS 6.2 x86_64 con nginx [ISPConfig 3]

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

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