GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Il server perfetto - Ubuntu 17.10 (Artful Aardvark) con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot e ISPConfig 3.1

Questo tutorial mostra l'installazione di un server di hosting Web Ubuntu 17.10 (Artful Aardvark) con Apache2, Postfix, Dovecot, Bind e PureFTPD per prepararlo all'installazione di ISPConfig 3.1. Il sistema risultante fornirà un server Web, Mail, Mailinglist, DNS e FTP.

ISPConfig 3 è un pannello di controllo di web hosting che permette di configurare i seguenti servizi attraverso 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 l'installazione di Apache (anziché Nginx), BIND (anziché MyDNS) e Dovecot (anziché Courier).

Questo tutorial riguarda Ubuntu 17.10, una versione non LTS (supporto a lungo termine). La maggior parte degli utenti preferisce una versione LTS come server che riceve aggiornamenti e patch di sicurezza per un tempo molto più lungo. L'ultima versione LTS è Ubuntu 16.04, questo tutorial esiste anche in una versione Ubuntu 16.04. Valuta attentamente se hai bisogno dei pacchetti più recenti (e non hai problemi con un breve periodo di supporto), quindi continua con questo tutorial. Se hai bisogno di un supporto di lunga data, usa invece il tutorial di Ubuntu 16.04 Perfect Server.

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 17.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. In seguito dovrebbe apparire così:

nano /etc/apt/sources.list
#

# deb cdrom:[Ubuntu-Server 17.10 _Artful Aardvark_ - Release amd64 (20171017.1)]/ artful main restricted

#deb cdrom:[Ubuntu-Server 17.10 _Artful Aardvark_ - Release amd64 (20171017.1)]/ artful 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/ artful main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ artful main restricted

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

deb http://security.ubuntu.com/ubuntu artful-security main restricted
# deb-src http://security.ubuntu.com/ubuntu artful-security main restricted
deb http://security.ubuntu.com/ubuntu artful-security universe
# deb-src http://security.ubuntu.com/ubuntu artful-security universe
deb http://security.ubuntu.com/ubuntu artful-security multiverse
# deb-src http://security.ubuntu.com/ubuntu artful-security multiverse

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. Secondo me, non è necessario per configurare un sistema sicuro e di solito causa più problemi che vantaggi (pensaci dopo aver eseguito una settimana di risoluzione dei problemi perché alcuni servizi non funzionavano come previsto, 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) su Internet quando si esegue un server fisico. Nel caso in cui tu esegua un server virtuale, dovresti saltare questo passaggio. Corri

apt-get -y install ntp

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

6. Installa Postfix, Dovecot, MariaDB, rkhunter e binutils

Per installare postfix, dobbiamo assicurarci che sendmail non sia installato e funzionante. Per interrompere e rimuovere sendmail esegui questo comando:

service sendmail stop; update-rc.d -f sendmail remove

Il messaggio di errore:

Failed to stop sendmail.service: Unit sendmail.service not loaded.

Va bene, significa solo che sendmail non è stato installato, quindi non c'era nulla da rimuovere.

Ora possiamo installare Postfix, Dovecot, MariaDB (come sostituto di MySQL), rkhunter e binutils con un solo comando:

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

Ti verranno poste le seguenti domande:

General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com

È importante utilizzare un sottodominio come "nome di posta di sistema" come server1.example.com o server1.tuodominio.com e non un dominio che desideri utilizzare come dominio di posta elettronica (es.tuodominio.tld) ​​in seguito.

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

NOTA:gli spazi bianchi davanti alle righe "-o .... " sono importanti!

Riavvia Postfix in seguito:

service postfix restart

Vogliamo che MySQL sia in ascolto su tutte le interfacce, non solo su localhost. Pertanto, modifichiamo /etc/mysql/mariadb.conf.d/50-server.cnf e commentiamo la riga bind-address =127.0.0.1 e aggiungiamo la riga sql-mode="NO_ENGINE_SUBSTITUTION" :

nano /etc/mysql/mariadb.conf.d/50-server.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

sql-mode="NO_ENGINE_SUBSTITUTION"

[...]

Ora impostiamo una password di root in MariaDB. Corri:

mysql_secure_installation

Ti verranno poste queste domande:

Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

Imposta il metodo di autenticazione della password in MariaDB su nativo in modo da poter utilizzare PHPMyAdmin in seguito per connetterci come utente root:

echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root

Modifica il file /etc/mysql/debian.cnf e imposta la password di root MYSQL/MariaDB due volte nelle righe che iniziano con password.

nano /etc/mysql/debian.cnf

La password di root MySQL che deve essere aggiunta è mostrata in read, in questo esempio la password è "howtoforge".

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = root
password = howtoforge
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password = howtoforge
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

Quindi riavviamo MariaDB:

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
tcp6 0 0 [::]:mysql [::]:* LISTEN 30591/mysqld
[email protected]:~#

7. Installa Amavisd-new, SpamAssassin e Clamav

Per installare amavisd-new, SpamAssassin e ClamAV, eseguiamo

apt-get -y 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 postgrey

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 avviare ClamAV usa:

freshclam
service clamav-daemon start

Il seguente errore può essere ignorato alla prima esecuzione di freshclam.

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).

7.1 Installare il server Metronome XMPP (opzionale)

Il server Metronome XMPP fornisce un server di chat XMPP. Questo passaggio è facoltativo, se non hai bisogno di un server di chat, puoi saltare questo passaggio. Nessun'altra funzione ISPConfig dipende da questo software.

Installa i seguenti pacchetti con apt.

apt-get -y install git lua5.1 liblua5.1-0-dev lua-filesystem libidn11-dev libssl-dev lua-zlib lua-expat lua-event lua-bitop lua-socket lua-sec luarocks luarocks
luarocks install lpc

Aggiungi un utente shell per Metronome.

adduser --no-create-home --disabled-login --gecos 'Metronome' metronome

Scarica Metronome nella directory /opt e compilalo.

cd /opt; git clone https://github.com/maranda/metronome.git metronome
cd ./metronome; ./configure --ostype=debian --prefix=/usr
make
make install

Metronome è ora installato su /opt/metronome.


Ubuntu
  1. Il server perfetto - Ubuntu 15.04 (Vivid Vervet) con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot e ISPConfig 3

  2. Il server perfetto - Ubuntu 15.10 (Wily Werewolf) con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, 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.10 (Yakkety Yak) con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot e ISPConfig 3.1

  5. Il server perfetto - Ubuntu 17.04 (Zesty Zapus) con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot e ISPConfig 3.1

Il server perfetto CentOS 7.4 con Apache, Postfix, Dovecot, Pure-FTPD, BIND e ISPConfig 3.1

Il server perfetto CentOS 7.6 con Apache, PHP 7.2, Postfix, Dovecot, Pure-FTPD, BIND e ISPConfig 3.1

Il server perfetto - Ubuntu 20.04 con Apache, PHP, MariaDB, PureFTPD, BIND, Postfix, Dovecot e ISPConfig 3.2

Il server perfetto CentOS 8 con Apache, PHP, Postfix, Dovecot, Pure-FTPD, BIND e ISPConfig 3.2

Il server perfetto - Ubuntu 14.04 (Apache2, PHP, MySQL, PureFTPD, BIND, Dovecot, ISPConfig 3)

Il server perfetto - Ubuntu 14.10 con Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot e ISPConfig