Serveur - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
Serveur - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
Serveur - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
Traduction du tutoriel The Perfect Server - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
Ce tutoriel montre comment préparer un serveur Debian 9 (avec Nginx, BIND, Dovecot) pour l’installation d’ISPConfig 3.1.
ISPConfig 3 est un panneau de contrôle d’hébergement web qui vous permet de configurer les services suivants via un navigateur web: serveur web Apache ou nginx, serveur de messagerie Postfix, serveur IMAP/POP3 Courier ou Dovecot, serveur MySQL, serveur de noms BIND ou MyDNS, PureFTPd, SpamAssassin, ClamAV, et bien d’autres. Cette configuration couvre le serveur web Nginx, BIND comme serveur DNS et Dovecot comme serveur IMAP / POP3.
Note préliminaire
Dans ce tutoriel, j’utilise le serveur hostname server1.example.com avec l’adresse IP 192.168.1.100 et la passerelle 192.168.1.1.1. Ces paramètres peuvent différer pour vous, vous devez donc les remplacer le cas échéant. Avant d’aller plus loin, vous devez avoir une installation minimale de Debian 9. Il peut s’agir d’une image minimale de Debian fournie par votre hébergeur ou une utilisation du tutoriel Minimal Debian Server pour configurer le système de base.
Configurer le nom d’hôte
Le nom d’hôte de votre serveur doit être un sous-domaine comme “server1.example.com”. N’utilisez pas un nom de domaine sans partie de sous-domaine comme “example. com” comme nom d’hôte car cela causera des problèmes plus tard avec la configuration de votre messagerie. Tout d’abord, vous devez vérifier le nom d’hôte dans /etc/hosts et le modifier si nécessaire. La ligne doit être:”Adresse IP - espace - nom d’hôte complet y compris domaine - espace - sous-domaine partie”. Editer /etc/hosts. Fais en sorte que ça ressemble à ça:
1
nano /etc/hosts
1
2
3
4
5
6
7
127.0.0.1 localhost.localdomain localhost
192.168.1.100 server1.example.com server1
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Puis éditez le fichier /etc/hostname
1
nano /etc/hostname
Il ne contiendra que la partie du sous-domaine
1
server1
Redémarrez le serveur pour appliquer le changement:
reboot
Connectez-vous à nouveau et vérifiez si le nom d’hôte est correct
1
2
hostname
hostname -f
La sortie doit être comme ceci:
1
2
3
4
root@server1:/tmp# hostname
server1
root@server1:/tmp# hostname -f
server1.example.com
Mettre à jour l’installation Debian
Tout d’abord, assurez-vous que votre fichier /etc/apt/sources.list contient le référentiel stretch/updates (ceci vous assure que vous recevez toujours les dernières mises à jour pour l’analyseur de virus ClamAV - ce projet publie des versions très souvent, et parfois les anciennes versions s’arrêtent de fonctionner), et que les référentiels contrib et non-libres sont activés.
1
nano /etc/apt/sources.list
1
2
3
4
5
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free
Exécuter
1
apt-get update
pour mettre à jour la base de données des paquets apt
1
apt-get upgrade
pour installer les dernières mises à jour.
Modifier le Shell par défaut
/bin/sh est un lien symbolique vers /bin/dash, cependant nous avons besoin de /bin/bash, pas /bin/dash. C’est pourquoi nous le configurons:
1
2
dpkg-reconfigure dash
Use dash as the default system shell (/bin/sh)? <-- No
Si vous ne le faites pas, l’installation d’ISPConfig échouera.
Synchroniser l’horloge système
Il est recommandé de synchroniser l’horloge système avec un serveur NTP (Network Time Protocol) sur Internet. Il suffit de lancer
1
apt-get install ntp
et l’heure de votre système sera toujours synchronisée.
Installer Postfix, Dovecot, MySQL, rkhunter et binutils
Nous pouvons installer Postfix, Dovecot, MySQL, rkhunter, et Binutils avec une seule commande:
1
apt-get 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
Les questions suivantes vous seront posées:
1
2
General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com
Pour sécuriser l’installation de MariaDB/MySQL et désactiver la base de données de test, exécutez cette commande:
1
mysql_secure_installation
Nous n’avons pas besoin de changer le mot de passe root de MySQL car nous en avons simplement défini un nouveau lors de l’installation. Répondez aux questions comme suit:
1
2
3
4
5
6
7
Change the root password? [Y/n] <-- y
New password: <-- Enter a new MySQL root password
Re-enter new password: <-- Repeat the MySQL root password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Remove test database and access to it? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y
Ensuite, ouvrez les ports TLS/SSL et de soumission dans Postfix:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[...]
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=
# -o smtpd_relay_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=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
[...]
Redémarrer postfix
1
service postfix restart
Nous voulons que MariaDB écoute sur toutes les interfaces, pas seulement localhost, donc nous éditons /etc/mysql/mariadb.conf.d/50-server.cnf et commentons la ligne bind-address = 127.0.0.1
et ajoutons la ligne sql-mode="NO_ENGINE_SUBSTITUTION"
1
nano /etc/mysql/mariadb.conf.d/50-server.cnf
1
2
3
4
5
6
7
8
9
[...]
# 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"
[...]
Définissez la méthode d’authentification par mot de passe en natif dans MariaDB pour que nous puissions utiliser PHPMyAdmin plus tard pour nous connecter en tant qu’utilisateur root
1
echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root
Editez le fichier /etc/mysql/debian.cnf et définissez le mot de passe root MYSQL/MariaDB deux fois dans les lignes qui commencent par “password”.
1
nano /etc/mysql/debian.cnf
Le mot de passe racine MySQL qui doit être ajouté est dans cet exemple, “howtoforge”.
1
2
3
4
5
6
7
8
9
10
11
12
# 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
Pour éviter l’erreur ‘Error in accept: Too many open files’ nous allons maintenant définir des limites plus élevées pour MariaDB.
1
nano /etc/security/limits.conf
et ajoutez ces lignes à la fin du fichier.
1
2
mysql soft nofile 65535
mysql hard nofile 65535
Ensuite, créez un nouveau répertoire /etc/systemd/system/mysql.service.d/
1
mkdir -p /etc/systemd/system/mysql.service.d/
et ajouter un nouveau fichier à l’intérieur
1
nano /etc/systemd/system/mysql.service.d/limits.conf
coller les lignes suivantes dans ce fichier
1
2
[Service]
LimitNOFILE=infinity
Sauvegardez le fichier et fermez l’éditeur nano.
Puis on recharge le système et on redémarre MariaDB
1
2
systemctl daemon-reload
service mysql restart
Vérifiez maintenant que la mise en réseau est activée.
1
netstat -tap | grep mysql
La sortie devrait ressembler à ceci
1
2
3
root@server1:~# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 4027/mysqld
root@server1:~#
Installer Amavisd-new, SpamAssassin et ClamAV
Pour installer amavisd-new, SpamAssassin et ClamAV
1
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 libdbd-mysql-perl postgrey
La configuration d’ISPConfig 3 utilise amavisd qui charge la bibliothèque de filtres SpamAssassin en interne, de sorte que nous pouvons arrêter SpamAssassin pour libérer un peu de RAM
1
2
service spamassassin stop
systemctl disable spamassassin
Installer Metronome XMPP Server (option)
Cette étape installe le Metronome XMPP Server qui fournit un serveur de chat compatible avec le protocole XMPP. Cette étape est facultative, si vous n’avez pas besoin d’un serveur de chat, vous pouvez sauter cette étape. Aucune autre fonction ISPConfig ne dépend de ce logiciel.
Ajouter le dépôt de paquets Prosody dans Debian.
1
2
echo "deb http://packages.prosody.im/debian stretch main" > /etc/apt/sources.list.d/metronome.list
wget http://prosody.im/files/prosody-debian-packages.key -O - | sudo apt-key add -
Mettre à jour la liste des paquets
apt-get updateInstaller les programmes nécessaires à la compilation
apt-get install build-essentialet installez les paquets avec apt.
apt-get 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 lpcAjouter un utilisateur shell pour Metronome.
adduser –no-create-home –disabled-login –gecos ‘Metronome’ metronomeTéléchargez Metronome dans le répertoire /opt et compilez-le.
1
2
3
4
cd /opt; git clone https://github.com/maranda/metronome.git metronome
cd ./metronome; ./configure --ostype=debian --prefix=/usr
make
make install
Metronome est maintenant installé dans /opt/metronome
Installer Nginx, PHP (PHP-FPM) et Fcgiwrap
Nginx est disponible sous forme de paquet pour Debian que nous pouvons installer
apt-get install nginxSi Apache2 est déjà installé sur le système, arrêtez-le maintenant…
service apache2 stopLe message “Failed to stop apache2.service: Unit apache2.service not loaded.” est correcte et n’indique pas d’erreur.
… et supprimer les liens de démarrage du système Apache
Démarrez nginx
service nginx start(Si Apache2 et nginx sont tous les deux installés, l’installateur d’ISPConfig 3 vous demandera lequel vous voulez utiliser - répondez nginx dans ce cas. Si une seule de ces deux options est installée, ISPConfig effectuera automatiquement la configuration nécessaire)
Nous pouvons faire fonctionner PHP 7 dans nginx à travers PHP-FPM (PHP-FPM (FastCGI Process Manager) est une implémentation alternative de PHP FastCGI avec quelques fonctionnalités supplémentaires utiles pour les sites de toute taille, en particulier les sites plus occupés)
apt-get install php7.0-fpmPHP-FPM est un processus démon qui exécute un serveur FastCGI sur le socket /var/run/php/php7.0-fpm.sock
Pour obtenir le support de MySQL en PHP, nous pouvons installer le paquet php7.0-mysql. C’est une bonne idée d’installer d’autres modules PHP aussi bien que vous pourriez en avoir besoin pour vos applications. Vous pouvez rechercher les modules PHP disponibles
apt-cache search php7Choisissez ceux dont vous avez besoin et installez-les
apt-get install php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-imap php7.0-cli php7.0-cgi php-pear php7.0-mcrypt mcrypt imagemagick libruby php7.0-curl php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl memcached php-memcache php-imagick php-gettext php7.0-zip php7.0-mbstring memcached php7.0-soap php7.0-opcacheOuvrez ensuite /etc/php/7.0/fpm/php.ini…
nano /etc/php/7.0/fpm/php.ini… mettez cgi. fix_pathinfo=0 et votre fuseau horaire
1
2
3
4
5
[...]
cgi.fix_pathinfo=0
[...]
date.timezone="Europe/Paris"
[...]
(Vous pouvez trouver tous les fuseaux horaires disponibles dans les répertoires /usr/share/zoneinfo et ses sous-répertoires.)
Rechargez PHP-FPM:
service php7.0-fpm reloadPour obtenir le support CGI dans nginx, nous installons Fcgiwrap.
Fcgiwrap est un wrapper CGI qui devrait fonctionner également pour les scripts CGI complexes et peut être utilisé pour les environnements d’hébergement mutualisé car il permet à chaque serveur virtuel d’utiliser son propre répertoire cgi-bin.
Installez le paquet fcgiwrap
Après l’installation, le démon fcgiwrap devrait déjà être lancé et sa socket est /var/run/fcgiwrap.socket S’il ne fonctionne pas, vous pouvez utiliser le service fcgiwrap pour le démarrer.
Maintenant, quand vous créez un vhost nginx, ISPConfig va s’occuper de la configuration correcte du vhost.
Versions PHP supplémentaires
A partir d’ISPConfig 3.0.5, il est possible d’avoir plusieurs versions PHP sur un même serveur (sélectionnable via ISPConfig) qui peuvent être exécutées via PHP-FPM, y compris PHP 5.x et 7.x. Pour apprendre comment construire des versions PHP supplémentaires (PHP-FPM) et comment configurer ISPConfig, veuillez consulter ce tutoriel: How to install PHP 7.1, 7.2 and 5.6 as PHP-FPM & FastCGI for ISPConfig 3 on Debian 9
Installer phpMyAdmin
Installer phpMyAdmin
1
apt-get install phpmyadmin
Ne sélectionnez pas d’option lorsque l’installateur demande “Web server to reconfigure automatically:” et appuyez sur ok.
1
2
3
Configure database for phpmyadmin with dbconfig-common? <-- yes
MySQL application password for phpmyadmin: <-- Press Enter
Password of the database's administrative user: <-- Enter the MySQL root password
Vous pouvez maintenant trouver phpMyAdmin dans le répertoire /usr/share/phpmyadmin/
Après avoir installé ISPConfig 3.1, vous pouvez accéder à phpMyAdmin.
L’ISPConfig apps vhost sur le port 8081 pour nginx est livré avec une configuration phpMyAdmin, vous pouvez donc utiliser http://server1.example.com:8081/phpmyadmin ou http://server1.example.com:8081/phpMyAdmin pour accéder à phpMyAdmin.
Si vous voulez utiliser un alias /phpmyadmin ou /phpMyAdmin que vous pouvez utiliser à partir de vos sites web, c’est un peu plus compliqué que pour Apache car nginx n’ a pas d’alias globaux (c’est-à-dire des alias qui peuvent être définis pour tous les vhosts). Par conséquent, vous devez définir ces alias pour chaque serveur virtuel à partir duquel vous voulez accéder à phpMyAdmin.
Pour ce faire, collez ce qui suit dans le champ Directives nginx de l’onglet Options du site web dans ISPConfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
Si vous utilisez https au lieu de http pour votre vhost, vous devez ajouter la ligne fastcgi_param HTTPS on; à votre configuration phpMyAdmin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS on; # <-- add this line
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
Si vous utilisez à la fois http et https pour votre serveur virtuel, vous pouvez utiliser la variable $https. Allez dans le champ Directives nginx à nouveau, et au lieu de fastcgi_param HTTPS on, vous ajoutez la ligne fastcgi_param HTTPS $https; vous pouvez donc utiliser phpMyAdmin pour les requêtes http et https
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS $https; # <-- add this line
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
Installer Let’s Encrypt
ISPConfig 3.1 est compatible avec l’autorité de certification SSL gratuite Let’s encrypt. La fonction Let’s Encrypt vous permet de créer des certificats SSL gratuits pour votre site Web à partir d’ISPConfig.
1
apt-get install certbot
Installer Mailman
ISPConfig vous permet de gérer (créer/modifier/supprimer) les listes de diffusion Mailman. Si vous souhaitez utiliser cette fonctionnalité, installez Mailman
1
apt-get install install mailman
Sélectionnez au moins une langue, par ex:
1
2
Languages to support: <-- en (English)
Missing site list <-- Ok
Avant que nous puissions démarrer Mailman, une première liste de diffusion appelée mailman doit être créée
1
newlist mailman
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Enter the email of the person running the list: <-- admin email address, e.g. listadmin@example.com
Initial mailman password: <-- admin password for the mailman list
To finish creating your mailing list, you must edit your /etc/aliases (or
equivalent) file by adding the following lines, and possibly running the
`newaliases' program:
## mailman mailing list
mailman: "|/var/lib/mailman/mail/mailman post mailman"
mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman"
mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman"
mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman"
mailman-join: "|/var/lib/mailman/mail/mailman join mailman"
mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman"
mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman"
mailman-request: "|/var/lib/mailman/mail/mailman request mailman"
mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"
Hit enter to notify mailman owner... <-- ENTER
root@server1:~#
Pouvrir ensuite /etc/aliases…
1
nano /etc/aliases
…ajoutez les lignes suivantes
1
2
3
4
5
6
7
8
9
10
11
12
[...]
## mailman mailing list
mailman: "|/var/lib/mailman/mail/mailman post mailman"
mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman"
mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman"
mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman"
mailman-join: "|/var/lib/mailman/mail/mailman join mailman"
mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman"
mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman"
mailman-request: "|/var/lib/mailman/mail/mailman request mailman"
mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"
Exécuter
1
newaliases
Redémarrer Postfix:
1
service postfix restart
Démarrer le daemon the Mailman
1
service mailman start
Après avoir installé ISPConfig 3, vous pouvez accéder à Mailman comme suit:
L’ISPConfig apps vhost sur le port 8081 pour nginx est livré avec une configuration Mailman, vous pouvez donc utiliser http://server1.example.com:8081/cgi-bin/mailman/admin/
Si vous voulez utiliser Mailman à partir de vos sites web, c’est un peu plus compliqué que pour Apache car nginx n’ a pas d’alias globaux (c’est-à-dire des alias qui peuvent être définis pour tous les vhosts). Par conséquent, vous devez définir ces alias pour chaque serveur virtuel à partir duquel vous souhaitez accéder à Mailman.
Pour ce faire, collez ce qui suit dans le champ Directives nginx de l’onglet Options du site web dans ISPConfig:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
location /cgi-bin/mailman {
root /usr/lib/;
fastcgi_split_path_info (^/cgi-bin/mailman/[^/]*)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /images/mailman {
alias /usr/share/images/mailman;
}
location /pipermail {
alias /var/lib/mailman/archives/public;
autoindex on;
}
Ceci définit l’alias /cgi-bin/mailman/ pour votre vhost, ce qui signifie que vous pouvez accéder à l’interface d’administration de Mailman pour une liste à http://
Sous http://
Installer PureFTPd et quota
PureFTPd et quota peuvent être installés avec la commande suivante
1
apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool
Editez le fichier /etc/default/pure-ftpd-common…
1
nano /etc/default/pure-ftpd-common
…. et assurez-vous que le mode de démarrage est réglé sur standalone et VIRTUALCHROOT=true:
1
2
3
4
5
[...]
STANDALONE_OR_INETD=standalone
[...]
VIRTUALCHROOT=true
[...]
Maintenant, nous configurons PureFTPd pour autoriser les sessions FTP et TLS. FTP est un protocole très peu sûr car tous les mots de passe et toutes les données sont transférés en texte clair. En utilisant TLS, l’ensemble de la communication peut être crypté, rendant ainsi FTP beaucoup plus sûr.
Si vous voulez autoriser les sessions FTP et TLS, exécutez
1
echo 1 > /etc/pure-ftpd/conf/TLS
Pour utiliser TLS, nous devons créer un certificat SSL. Je le crée dans /etc/ssl/private/, donc je crée d’abord ce répertoire:
1
mkdir -p /etc/ssl/private/
Ensuite, nous pouvons générer le certificat SSL
1
openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
1
2
3
4
5
6
7
Country Name (2 letter code) [AU]: <-- Enter your Country Name (e.g., "DE").
State or Province Name (full name) [Some-State]:<-- Enter your State or Province Name.
Locality Name (eg, city) []:<-- Enter your City.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:<-- Enter your Organization Name (e.g., the name of your company).
Organizational Unit Name (eg, section) []:<-- Enter your Organizational Unit Name (e.g. "IT Department").
Common Name (eg, YOUR name) []:<-- Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com").
Email Address []:<-- Enter your Email Address.
Modifier les permissions du certificat SSL
1
chmod 600 /etc/ssl/private/pure-ftpd.pem
Redémarrez ensuite PureFTPd
1
service pure-ftpd-mysql restart
Editer /etc/fstab. ajouté usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 à la partition avec le point de montage /
1
nano /etc/fstab
1
2
3
4
5
6
7
8
9
10
11
12
# /etc/fstab: static file system information.
#
# Use 'blkid' 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>
# / was on /dev/sda1 during installation
UUID=f539c5cb-624f-4c27-a149-1446a251a453 / ext4 errors=remount-ro,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 1
# swap was on /dev/sda5 during installation
UUID=8d3194e7-edb5-4492-937d-d066b4994baf none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
Pour activer le quota, exécutez ces commandes
1
2
3
4
mount -o remount /
quotacheck -avugm
quotaon -avug
Installer le serveur DNS BIND
BIND peut être installé
apt-get install bind9 dnsutilsSi votre serveur est une machine virtuelle, il est fortement recommandé d’installer le démon haveged daemon pour obtenir une entropie plus élevée pour la signature DNSSEC. Vous pouvez aussi installer haveged sur des serveurs non virtuels
1
2
3
apt-get install haveged
systemctl enable haveged
service haveged start
Une explication sur ce sujet se trouve ici.
Installer Webalizer et AWStats
Webalizer et AWStats peuvent être installés comme suit
1
apt-get install webalizer awstats geoip-database libtimedate-perl libclass-dbi-mysql-perl
Ouvrez ensuite /etc/cron.d/awstats…
1
nano /etc/cron.d/awstats
…et commenter tout ce qu’il y a dans ce dossier
1
2
3
4
5
6
#MAILTO=root
#*/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
Installer Jailkit
Jailkit n’est nécessaire que si vous voulez chrooter les utilisateurs SSH. Il peut être installé comme suit (important: Jailkit doit être installé avant ISPConfig - il ne peut pas être installé après!):
1
apt-get install build-essential autoconf automake libtool flex bison debhelper binutils
1
2
3
4
5
6
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.19.tar.gz
tar xvfz jailkit-2.19.tar.gz
cd jailkit-2.19
echo 5 > debian/compat
./debian/rules binary
Vous pouvez maintenant installer le paquet Jailkit.deb comme suit
1
2
3
cd ..
dpkg -i jailkit_2.19-1_*.deb
rm -rf jailkit-2.19*
Installer Fail2ban et UFW Firewall
C’est optionnel mais recommandé, car le moniteur ISPConfig essaie d’afficher le journal:
1
apt-get install fail2ban
Pour avoir fail2ban monitor PureFTPd et Dovecot, créer le fichier /etc/fail2ban/jail.local
1
nano /etc/fail2ban/jail.local
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[pure-ftpd]
enabled = true
port = ftp
filter = pure-ftpd
logpath = /var/log/syslog
maxretry = 3
[dovecot]
enabled = true
filter = dovecot
logpath = /var/log/mail.log
maxretry = 5
[postfix-sasl]
enabled = true
port = smtp
filter = postfix-sasl
logpath = /var/log/mail.log
maxretry = 3
Redémarrer fail2ban
1
service fail2ban restart
Pour installer le parefeu UFW
1
apt-get install ufw
Installer RoundCube
Installez RoundCube
apt-get install roundcube roundcube-core roundcube-mysql roundcube-pluginsL’installateur posera les questions suivantes
1
2
3
Configure database for roundcube with dbconfig.common? <-- yes
MySQL application password for roundcube: <-- press enter
Password of the databases administrative user: <-- enter the MySQL root password here.
Puis éditez le fichier RoundCube /etc/roundcube/config.inc.php et ajustez quelques paramètres
nano /etc/roundcube/config.inc.phpDéfinissez les paramètres default_host et smtp_server sur localhost
1
2
$config['default_host'] = 'localhost';
$config['smtp_server'] = 'localhost';
ISPConfig a une certaine configuration dans l’application nginx vhost pour squirrelmail qui fonctionne aussi pour roundcube. Nous l’activons
ln -s /usr/share/roundcube /usr/share/squirrelmailVous pouvez maintenant accéder à RoundCube
http://192.168.1.100:8081/webmail http://server1.example.com:8081/webmail (après avoir installé ISPConfig)Installer ISPConfig 3
Avant de démarrer l’installation d’ISPConfig, assurez-vous qu’Apache est arrêté (si elle est installée - il est possible que certains de vos paquets installés aient installé Apache en tant que dépendance sans que vous le sachiez). Si Apache2 est déjà installé sur le système, arrêtez-le maintenant…
1
service apache2 stop
…et supprimer les liens de démarrage du système Apache
1
update-rc.d -f apache2 remove
Assurez-vous que Nginx fonctionne
1
service nginx restart
(Si vous avez Apache et nginx installés, le programme d’installation vous demande lequel vous voulez utiliser: Apache et nginx détectés. Sélectionnez le serveur à utiliser pour ISPConfig: (apache, nginx)
Tapez nginx. Si seulement Apache ou nginx sont installés, ceci est automatiquement détecté par l’installateur, et aucune question n’est posée).
Pour installer ISPConfig 3.1 à partir de la dernière version disponible
1
2
3
4
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/
L’étape suivante consiste à exécuter
1
php -q install.php
Cela lancera l’installateur d’ISPConfig 3. L’installateur configurera pour vous tous les services comme Postfix, Niginx, Dovecot, etc…
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--------------------------------------------------------------------------------
_____ ___________ _____ __ _ ____
|_ _/ ___| ___ \ / __ \ / _(_) /__ \
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ /
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/
__/ |
|___/
--------------------------------------------------------------------------------
>> Initial configuration
Operating System: Debian 9.0 (Stretch) or compatible
Following will be a few questions for primary configuration so be careful.
Default values are in [brackets] and can be accepted with <ENTER>.
Tap in "quit" (without the quotes) to stop the installer.
Select language (en,de) [en]: <-- Hit Enter
Installation mode (standard,expert) [standard]: <-- Hit Enter
Full qualified hostname (FQDN) of the server, eg server1.domain.tld [server1.canomi.com]: <-- Hit Enter
MySQL server hostname [localhost]: <-- Hit Enter
MySQL server port [3306]: <-- Hit Enter
MySQL root username [root]: <-- Hit Enter
MySQL root password []: <-- Enter your MySQL root password
MySQL database to create [dbispconfig]: <-- Hit Enter
MySQL charset [utf8]: <-- Hit Enter
Apache and nginx detected. Select server to use for ISPConfig: (apache,nginx) [apache]: <-- nginx
Configuring Postgrey
Configuring Postfix
Generating a 4096 bit RSA private key
.......................................................................++
........................................................................................................................................++
writing new private key to 'smtpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: <-- Enter 2 letter country code
State or Province Name (full name) [Some-State]: <-- Enter the name of the state
Locality Name (eg, city) []: <-- Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter company name or press enter
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <-- Enter the server hostname, in my case: server1.example.com
Email Address []: <-- Hit Enter
Configuring Mailman
Configuring Dovecot
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring BIND
Configuring Jailkit
Configuring Pureftpd
Configuring Nginx
Configuring vlogger
Configuring Metronome XMPP Server
writing new private key to 'localhost.key'
-----
Country Name (2 letter code) [AU]: <-- Enter 2 letter country code
Locality Name (eg, city) []: <-- Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter company name or press enter
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (e.g. server FQDN or YOUR name) [server1.canomi.com]: <-- Enter the server hostname, in my case: server1.example.com
Email Address []: <-- Hit Enter
Configuring UFW Firewall
Configuring Fail2ban
[INFO] service OpenVZ not detected
Configuring Apps vhost
Installing ISPConfig
ISPConfig Port [8080]:
Admin password [admin]: <-- Enter desired ISPConfig admin user password here
Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <-- Hit Enter
Generating RSA private key, 4096 bit long modulus
.......................++
................................................................................................................................++
e is 65537 (0x10001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: <-- Enter 2 letter country code
State or Province Name (full name) [Some-State]: <-- Enter the name of the state
Locality Name (eg, city) []: <-- Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter company name or press enter
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <-- Enter the server hostname, in my case: server1.example.com
Email Address []: <-- Hit Enter
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <-- Hit Enter
An optional company name []: <-- Hit Enter
writing RSA key
Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Detect IP addresses
Restarting services ...
Installation completed.
L’installateur configure automatiquement tous les services sous-jacents, aucune configuration manuelle n’est donc nécessaire.
Ensuite, vous pouvez accéder à ISPConfig 3 sous http (s): //server1. example. com: 8080/ ou http (s): //192.168.1.100:8080/ (http ou https dépend de ce que vous avez choisi pendant l’installation). Connectez-vous avec le nom d’utilisateur admin et le mot de passe admin (vous devez changer le mot de passe par défaut après votre première connexion)