GNU/Linux >> Tutoriels Linux >  >> Panels >> Panels

Le serveur parfait - CentOS 6.2 x86_64 avec nginx [ISPConfig 3]

Le serveur parfait - CentOS 6.2 x86_64 avec nginx [ISPConfig 3]

Ce tutoriel montre comment préparer un serveur CentOS 6.2 x86_64 pour l'installation d'ISPConfig 3, et comment installer ISPConfig 3. 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 nginx, Postfix serveur de messagerie, MySQL, serveur de noms BIND, PureFTPd, SpamAssassin, ClamAV, Mailman et bien d'autres. Depuis la version 3.0.4, ISPConfig est livré avec un support complet pour le serveur Web nginx en plus d'Apache ; ce tutoriel couvre la configuration d'un serveur qui utilise nginx, pas Apache.

Veuillez noter que cette configuration ne fonctionne pas pour ISPConfig 2 ! Il n'est valable que pour ISPConfig 3 !

Je n'émets aucune garantie que cela fonctionnera pour vous !

Manuel ISPConfig 3

Afin d'apprendre à utiliser ISPConfig 3, je vous recommande fortement de télécharger le manuel ISPConfig 3.

Sur environ 300 pages, il couvre le concept derrière ISPConfig (administrateur, revendeurs, clients), explique comment installer et mettre à jour ISPConfig 3, inclut une référence pour tous les formulaires et champs de formulaire dans ISPConfig ainsi que des exemples d'entrées valides, et fournit des tutoriels pour les tâches les plus courantes dans ISPConfig 3. Il explique également comment rendre votre serveur plus sécurisé et est accompagné d'une section de dépannage à la fin.

Application de surveillance ISPConfig pour Android

Avec l'application ISPConfig Monitor, vous pouvez vérifier l'état de votre serveur et savoir si tous les services fonctionnent comme prévu. Vous pouvez vérifier les ports TCP et UDP et envoyer un ping à vos serveurs. En plus de cela, vous pouvez utiliser cette application pour demander des détails aux serveurs sur lesquels ISPConfig est installé (veuillez noter que la version minimale installée d'ISPConfig 3 avec prise en charge de l'application ISPConfig Monitor est 3.0.3.3 ! ); ces détails incluent tout ce que vous savez du module Monitor dans le panneau de configuration ISPConfig (par exemple, les services, les journaux de messagerie et système, la file d'attente de messagerie, les informations sur le processeur et la mémoire, l'utilisation du disque, les quotas, les détails du système d'exploitation, le journal RKHunter, etc.), et bien sûr , comme ISPConfig est compatible avec plusieurs serveurs, vous pouvez vérifier tous les serveurs contrôlés à partir de votre serveur maître ISPConfig.

Pour obtenir des instructions de téléchargement et d'utilisation, veuillez visiter http://www.ispconfig.org/ispconfig-3/ispconfig-monitor-app-for-android/.

1 Exigences

Pour installer un tel système, vous aurez besoin des éléments suivants :

  • Téléchargez les deux DVD CentOS 6.2 depuis un miroir à côté de vous (la liste des miroirs se trouve ici :http://isoredirect.centos.org/centos/6/isos/x86_64/).
  • une connexion Internet rapide.

2 Remarque préliminaire

Dans ce tutoriel, j'utilise le nom d'hôte server1.example.com avec l'adresse IP 192.168.0.100 et la passerelle 192.168.0.1. Ces paramètres peuvent différer pour vous, vous devez donc les remplacer le cas échéant.

3 Installer le système de base

Démarrez à partir de votre premier DVD CentOS 6.2 (DVD 1). Sélectionnez Installer ou mettre à niveau un système existant :

Le test du support d'installation peut prendre beaucoup de temps, nous sautons donc ce test ici :

L'écran de bienvenue du programme d'installation de CentOS apparaît. Cliquez sur Suivant :

Choisissez ensuite votre langue :

Sélectionnez votre disposition de clavier :

Je suppose que vous utilisez un disque dur connecté localement, vous devez donc sélectionner Périphériques de stockage de base ici :

Vous pouvez voir l'avertissement suivant - Avertissement de périphérique de stockage. Si vous voyez ceci, cliquez sur le bouton Oui, supprimer toutes les données pour continuer :

Renseignez le nom d'hôte du serveur (ex. serveur1.exemple.com), puis cliquez sur le bouton Configurer le réseau :

Allez dans l'onglet Wired, sélectionnez l'interface réseau (probablement eth0) et cliquez sur Edit... :

Cochez la case Se connecter automatiquement et accédez à l'onglet Paramètres IPv4 et sélectionnez Manuel dans le menu déroulant Méthode. Renseignez un, deux ou trois serveurs de noms (séparés par une virgule) dans le champ Serveurs DNS (par exemple 8.8.8.8,8.8.4.4), puis cliquez sur le bouton Ajouter à côté de la zone Adresses :

Donnez maintenant à votre carte réseau une adresse IP statique et un masque de réseau (dans ce didacticiel, j'utilise l'adresse IP 192.168.0.100 et le masque de réseau 255.255.255.0 à des fins de démonstration ; si vous n'êtes pas sûr des bonnes valeurs, http://www. subnetmask.info pourrait vous aider). Renseignez également votre passerelle (ex. 192.168.0.1) et cliquez sur le bouton Appliquer... :

La configuration du réseau est maintenant terminée. Cliquez sur le bouton Suivant :

Le serveur parfait - CentOS 6.2 x86_64 avec nginx [ISPConfig 3] - Page 2

4 Ajuster /etc/hosts

Ensuite, nous éditons /etc/hosts. Faites en sorte qu'il ressemble à ceci :

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

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

5 Configurer le pare-feu

(Vous pouvez ignorer ce chapitre si vous avez déjà désactivé le pare-feu à la fin de l'installation de base du système.)

Je souhaite installer ISPConfig à la fin de ce tutoriel qui est livré avec son propre pare-feu. C'est pourquoi je désactive maintenant le pare-feu CentOS par défaut. Bien sûr, vous êtes libre de le laisser allumé et de le configurer selon vos besoins (mais vous ne devriez pas utiliser d'autre pare-feu plus tard car il interférera très probablement avec le pare-feu CentOS).

Exécuter

system-config-firewall

et désactiver le pare-feu.

Pour vérifier que le pare-feu a bien été désactivé, vous pouvez lancer

iptables -L 

ensuite. Le résultat devrait ressembler à ceci :

[[email protected] ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target prot opt source               destination

Chaîne OUTPUT (policy ACCEPT)
target     prot opt source               destination
[[email protected] ~]#

6 Désactiver SELinux

SELinux est une extension de sécurité de CentOS qui devrait fournir une sécurité étendue. À mon avis, vous n'en avez pas besoin pour configurer un système sécurisé, et cela cause généralement plus de problèmes que d'avantages (pensez-y après avoir effectué une semaine de dépannage car un service ne fonctionnait pas comme prévu, puis vous découvrir que tout allait bien, seul SELinux causait le problème). Par conséquent, je le désactive (c'est indispensable si vous souhaitez installer ISPConfig plus tard).

Modifiez /etc/selinux/config et définissez SELINUX=disabled :

vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Ensuite, nous devons redémarrer le système :

reboot

7 Activer des référentiels supplémentaires et installer certains logiciels

Nous importons d'abord les clés GPG pour les packages logiciels :

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

Ensuite, nous activons les référentiels RPMforge et EPEL sur notre système CentOS car de nombreux packages que nous allons installer au cours de ce didacticiel ne sont pas disponibles dans les référentiels CentOS 6.2 officiels :

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

cd /tmp
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release- 0.5.2-2.el6.rf.x86_64.rpm

(Si le lien ci-dessus ne fonctionne plus, vous pouvez trouver la version actuelle de rpmforge-release ici :http://packages.sw.be/rpmforge-release/)

rpm --import https://fedoraproject.org/static/0608B895.txt
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch. rpm
rpm -ivh epel-release-6-5.noarch.rpm

Nous devons également activer le dépôt Remi RPM qui contient le package php-fpm que nous installerons plus tard :

rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum install yum-priorities

Modifier /etc/yum.repos.d/epel.repo...

vi /etc/yum.repos.d/epel.repo

... et ajoutez la ligne priority=10 à la section [epel] :

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
priority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
[...]

Ensuite, faites de même pour la section [remi] dans /etc/yum.repos.d/remi.repo, plus le changement enabled à 1 :

vi /etc/yum.repos.d/remi.repo
[remi]
name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
priority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

[remi-test]
name=Les RPM de remi en test pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/test/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/test/mirror
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Ensuite, nous mettons à jour nos packages existants sur le système :

yum update

Maintenant, nous installons certains packages logiciels qui seront nécessaires plus tard :

yum groupinstall 'Development Tools'

8 quotas

(Si vous avez choisi un schéma de partitionnement différent du mien, vous devez ajuster ce chapitre afin que le quota s'applique aux partitions où vous en avez besoin.)

Pour installer le quota, nous exécutons cette commande :

yum install quota

Modifiez /etc/fstab et ajoutez ,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 à la partition / (/dev/mapper/vg_server1-lv_root) :

vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Dec 16 00:22:26 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_server1-lv_root /                       ext4    defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0        1 1
UUID=d995c881-fbc7-409f-bcad-86d255331a3f /boot                   ext4    defaults        1 2
/dev/mapper/vg_server1-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0

Puis lancez

mount -o remount /

quotacheck -avugm
quotaon -avug

pour activer le quota.

9 Synchroniser l'horloge système

C'est une bonne idée de synchroniser l'horloge système avec un NTP (n réseau t temps p rotocol) sur Internet. Exécutez simplement

yum install ntp

et l'heure de votre système sera toujours synchronisée.

10 Installer MySQL

Installez MySQL comme suit :

yum install mysql mysql-server

Créez ensuite les liens de démarrage du système pour MySQL et démarrez-le :

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

Définissez des mots de passe pour le compte racine MySQL :

mysql_secure_installation

[[email protected] tmp]# mysql_secure_installation




REMARQUE : L'EXÉCUTION DE TOUTES PARTIES DE CE SCRIPT EST RECOMMANDÉE POUR TOUS MySQL
      SERVEURS EN PRODUCTION UTILISER! VEUILLEZ LIRE ATTENTIVEMENT CHAQUE ÉTAPE !


Pour vous connecter à MySQL pour le sécuriser, nous aurons besoin du mot de passe
actuel pour l'utilisateur root. Si vous venez d'installer MySQL et 
vous n'avez pas défini le mot de passe root encore, le mot de passe sera vide,
vous devez donc juste appuyer sur entrée ici.

Entrez mot de passe actuel pour root (entre pour aucun) :
OK, mot de passe utilisé avec succès, passons à ...

La définition du mot de passe root assure que personne ne peut se connecter à la racine MySQL
utilisateur sans l'autorisation appropriée.

Définir le mot de passe root ? [O/n] <-- ENTRER
Nouveau mot de passe : <-- votremotdepasseqlracine
Saisir à nouveau le nouveau mot de passe : <-- votremotdepasseqlracine
Mot de passe mis à jour avec succès !
Rechargement des tableaux de privilèges. .
 ... Succès !


Par défaut, une installation de MySQL a un utilisateur anonyme, permettant à n'importe qui
de se connecter à MySQL sans avoir d'avoir un compte d'utilisateur créé pour
eux. Ceci est un conçu uniquement pour les tests, et pour rendre l'installation 
un peu plus fluide. Vous devriez les supprimer avant de passer dans un 
environnement de production.

Supprimer les utilisateurs anonymes ? [O/n] <-- ENTER
 ... Succès !

Normalement, root ne doit être autorisé à se connecter depuis 'localhost'. Cela
assure que quelqu'un ne ne peut pas deviner le mot de passe root depuis le réseau.

Interdire la connexion root à distance ? [O/n] <-- ENTER
 ... Succès !

Par défaut, MySQL est fourni avec une base de données nommée "test" à laquelle n'importe qui peut
accéder. Cela est également conçu uniquement pour les tests et devrait être supprimé 
avant de passer dans un environnement de production .

Supprimer la base de données de test et y accéder ? [O/n] <-- ENTER
 - Suppression de la base de données de test...
 ... Réussite !
 - Suppression des privilèges sur la base de données de test...
 ... Réussite !

Recharger les tableaux de privilèges garantira que tout les changements apportés jusqu'à présent 
prendront effet immédiatement.

Recharger les tableaux de privilèges maintenant ? [O/n] <-- ENTER
 ... Réussi !

Nettoyage ...



Tout fait ! Si vous avez complété toutes les étapes ci-dessus, votre installation de MySQL
devrait maintenant être sécurisée.

Merci d'utiliser MySQL !


[exemple @unixlinux.online tmp]#

Le serveur parfait - CentOS 6.2 x86_64 avec nginx [ISPConfig 3] - Page 4

11 Installer Courier-IMAP, Courier-Authlib et Maildrop

Malheureusement, il n'y a pas de packages RPM pour Courier-IMAP, Courier-Authlib et Maildrop, nous devons donc les créer nous-mêmes.

Supprimez d'abord Dovecot (CentOS 6.2 est livré avec Dovecot 2.x ; malheureusement, ISPConfig 3 prend en charge Dovecot 1.2.x, mais pas 2.x) :

yum remove dovecot dovecot-mysql

Ensuite, installez les prérequis dont nous avons besoin pour créer des packages Courier rpm :

yum install rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel libidn-devel

Les packages RPM ne doivent pas être compilés en tant que root; courier-imap refusera même de compiler s'il détecte que la compilation est exécutée en tant qu'utilisateur root. Par conséquent, nous créons maintenant un compte d'utilisateur normal (falko dans cet exemple) et lui donnons un mot de passe :

useradd -m -s /bin/bash falko
passwd falko

Nous aurons besoin de la commande sudo plus tard pour que l'utilisateur falko puisse compiler et installer les packages rpm. Mais d'abord, nous devons autoriser falko à exécuter toutes les commandes en utilisant sudo :

Exécuter

visudo

Dans le fichier qui s'ouvre, il y a une racine de ligne ALL=(ALL) ALL. Ajoutez une ligne similaire pour falko juste en dessous de cette ligne :

[...]
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
falko   ALL=(ALL)       ALL
[...]

Nous sommes maintenant prêts à construire notre package rpm. Devenez d'abord l'utilisateur falko :

su falko

Ensuite, nous créons notre environnement de construction :

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/BUILDROOT
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
mkdir $HOME/rpm/RPMS/x86_64

echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

Maintenant, nous créons un répertoire de téléchargements et téléchargeons les fichiers source depuis http://www.courier-mta.org/download.php :

mkdir $HOME/téléchargements
cd $HOME/téléchargements

wget https://sourceforge.net/projects/courier/files/authlib/0.63.0/courier-authlib-0.63.0.tar.bz2/download
wget https://sourceforge.net/projects/courier /files/imap/4.9.3/courier-imap-4.9.3.tar.bz2/download
wget https://sourceforge.net/projects/courier/files/maildrop/2.5.5/maildrop-2.5 .5.tar.bz2/download

(Veuillez noter que j'utilise Courier-IMAP 4.9.3 ici au lieu du plus récent 4.10.0 car 4.10.0 dépend de systemctl qui existe pour Fedora, mais pas pour CentOS.)

Maintenant (toujours dans $HOME/downloads) nous pouvons construire courier-authlib :

sudo rpmbuild -ta courier-authlib-0.63.0.tar.bz2

Après le processus de construction, les packages rpm se trouvent dans /root/rpmbuild/RPMS/x86_64 (/root/rpmbuild/RPMS/i686 si vous êtes sur un système i686). La commande

sudo ls -l /root/rpmbuild/RPMS/x86_64

vous montre les packages RPM disponibles :

[[email protected] downloads]$ sudo ls -l /root/rpmbuild/RPMS/x86_64
total 528
-rw-r--r-- 1 root root 124008 Dec 16 01:10 courier -authlib-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine 270860 16 décembre 01:10 courier-authlib-debuginfo-0.63.0-1.el6. x86_64.rpm
-rw-r--r-- 1 racine racine  35072 16 déc 01:10 courier-authlib-devel-0.63.0-1.el6.x86_64.rpm
-rw-r --r-- 1 racine racine  17368 16 déc 01:10 courier-authlib-ldap-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine  13928 16 décembre 01:10 courier-authlib-mysql-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13076 16 décembre 01:10 courier-authlib-pgsql-0.63. 0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine   8312 16 déc 01:10 courier-authlib-pipe-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  34064 16 déc 01:10 courier-authlib-userdb-0.63.0-1.el6.x86_64.rpm
[[email protected] downloads]$

Sélectionnez ceux que vous souhaitez installer et installez-les comme ceci :

sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-0.63.0-1.el6.x86_64.rpm /root/rpmbuild/RPMS/x86_64/courier-authlib-mysql-0.63.0-1.el6.x86_64.rpm /root/rpmbuild/RPMS/x86_64/courier-authlib-devel-0.63.0-1.el6.x86_64.rpm

Revenons maintenant à notre répertoire de téléchargement :

cd $HOME/downloads

Exécutez les commandes suivantes pour créer les répertoires requis/modifier les autorisations de répertoire (car sinon le processus de génération de Courier-Imap échouera) :

sudo mkdir -p /var/cache/ccache/tmp
sudo chmod o+rwx /var/cache/ccache/
sudo chmod 777 /var/cache/ccache/tmp

Maintenant, lancez à nouveau rpmbuild, cette fois sans sudo, sinon la compilation échouera car elle a été exécutée en tant que root :

rpmbuild -ta courier-imap-4.9.3.tar.bz2

Après le processus de construction, les packages rpm peuvent être trouvés dans $HOME/rpm/RPMS/x86_64 ($HOME/rpm/RPMS/i686 si vous êtes sur un système i686) :

cd $HOME/rpm/RPMS/x86_64

La commande

ls -l

vous montre les packages RPM disponibles :

[[email protected] x86_64]$ ls -l
total 1116
-rw-rw-r-- 1 falko falko 331908 16 décembre 01:33 courier-imap-4.9.3-1.x86_64 .rpm
-rw-rw-r-- 1 falko falko 800864 16 décembre 01:33 courier-imap-debuginfo-4.9.3-1.x86_64.rpm
[[email protected] x86_64] $

Vous pouvez installer courier-imap comme ceci :

sudo rpm -ivh courier-imap-4.9.3-1.x86_64.rpm

Revenons maintenant à notre répertoire de téléchargement :

cd $HOME/downloads

et exécutez à nouveau rpmbuild, cette fois pour créer un package maildrop :

sudo rpmbuild -ta maildrop-2.5.5.tar.bz2

Après le processus de construction, les packages rpm se trouvent dans /root/rpmbuild/RPMS/x86_64 (/root/rpmbuild/RPMS/i686 si vous êtes sur un système i686). La commande

sudo ls -l /root/rpmbuild/RPMS/x86_64

vous montre les packages RPM disponibles :

[[email protected] downloads]$ sudo ls -l /root/rpmbuild/RPMS/x86_64
total 1712
-rw-r--r-- 1 root root 124008 Dec 16 01:10 courier -authlib-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine 270860 16 décembre 01:10 courier-authlib-debuginfo-0.63.0-1.el6. x86_64.rpm
-rw-r--r-- 1 racine racine  35072 16 déc 01:10 courier-authlib-devel-0.63.0-1.el6.x86_64.rpm
-rw-r --r-- 1 racine racine  17368 16 déc 01:10 courier-authlib-ldap-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine  13928 16 décembre 01:10 courier-authlib-mysql-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13076 16 décembre 01:10 courier-authlib-pgsql-0.63. 0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine   8312 16 déc 01:10 courier-authlib-pipe-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 racine racine  34064 16 décembre 01:10 courier-authlib-userdb-0.63.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 286480 16 déc 01:40 maildrop-2.5.5-1.x86_64.rpm
-rw-r--r-- 1 root root 751376 16 déc 01:40 maildrop-debuginfo-2.5.5- 1.x86_64.r pm
-rw-r--r-- 1 root root 102104 16 déc 01:40 maildrop-devel-2.5.5-1.x86_64.rpm
-rw-r--r-- 1 root root  65940 16 décembre 01:40 maildrop-man-2.5.5-1.x86_64.rpm
[[email protected] downloads]$

Vous pouvez maintenant installer maildrop comme ceci :

sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/maildrop-2.5.5-1.x86_64.rpm

Après avoir compilé et installé tous les packages nécessaires, vous pouvez redevenir root en tapant

exit

Démarrez maintenant Courier-IMAP/-POP3 comme suit :

/etc/init.d/courier-imap start 

12 Installer Postfix

Postfix peut être installé comme suit :

yum install postfix

Ensuite, désactivez Sendmail et démarrez Postfix :

chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
/etc/init.d/sendmail stop
/etc/init.d/postfix restart

13 Installer Getmail

Getmail peut être installé comme suit :

yum install getmail

14 Installer Amavisd-new, SpamAssassin et ClamAV

Pour installer amavisd-new, spamassassin et clamav, exécutez la commande suivante :

yum install amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql

Ensuite, nous commençons freshclam, amavisd et clamd.amavisd :

sa-update
chkconfig --levels 235 amavisd sur
chkconfig --del clamd
chkconfig --levels 235 clamd.amavisd sur
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd.amavisd start

Le serveur parfait - CentOS 6.2 x86_64 avec nginx [ISPConfig 3] - Page 5

15 Installer Nginx, PHP5 (PHP-FPM) et Fcgiwrap

Nginx est disponible sous forme de package pour CentOS 6.2 (de EPEL) que nous pouvons installer comme suit :

yum install nginx

Si Apache2 est déjà installé sur le système, arrêtez-le maintenant...

/etc/init.d/httpd stop

... et supprimer les liens de démarrage du système d'Apache :

chkconfig --del httpd

Ensuite, nous créons les liens de démarrage du système pour nginx et le démarrons :

chkconfig --levels 235 nginx on
/etc/init.d/nginx start

(Si Apache2 et nginx sont installés, le programme d'installation d'ISPConfig 3 vous demandera lequel vous souhaitez utiliser - répondez nginx dans ce cas. Si un seul de ces deux éléments est installé, ISPConfig effectuera automatiquement la configuration nécessaire.)

Nous pouvons faire fonctionner PHP5 dans nginx via 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 les plus fréquentés). Nous pouvons installer php-fpm avec php-cli et certains modules PHP5 comme php-mysql dont vous avez besoin si vous souhaitez utiliser MySQL à partir de vos scripts PHP comme suit :

yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-xcache php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

Ensuite, nous ouvrons /etc/php.ini...

vi /etc/php.ini

... et modifier le rapport d'erreur (pour que les avis ne soient plus affichés) :

[...]
;error_reporting = E_ALL & ~E_DEPRECATED
error_reporting = E_ALL & ~E_NOTICE
[...]

Définissez également cgi.fix_pathinfo=0 :

vi /etc/php.ini
[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0
[...]

(Veuillez lire http://wiki.nginx.org/Pitfalls pour savoir pourquoi vous devriez faire cela.)

En plus de cela, afin d'éviter des erreurs telles que

[08-Aug-2011 18:07:08] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /usr/share/nginx/html/info.php on line 2

... dans /var/log/php-fpm/www-error.log lorsque vous appelez un script PHP dans votre navigateur, vous devez définir date.timezone dans /etc/php.ini :

[...]
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = "Europe/Berlin"
[...]

Vous pouvez trouver le fuseau horaire correct pour votre système en exécutant :

cat /etc/sysconfig/clock

[[email protected] tmp]# cat /etc/sysconfig/clock
ZONE="Europe/Berlin"
[[email protected] tmp]#

Créez ensuite les liens de démarrage du système pour php-fpm et démarrez-le :

chkconfig --levels 235 php-fpm on
/etc/init.d/php-fpm start

PHP-FPM est un processus démon (avec le script d'initialisation /etc/init.d/php-fpm) qui exécute un serveur FastCGI sur le port 9000.

Pour obtenir le support CGI dans nginx, nous installons Fcgiwrap.

Fcgiwrap est un wrapper CGI qui devrait également fonctionner pour les scripts CGI complexes et peut être utilisé pour les environnements d'hébergement partagé car il permet à chaque vhost d'utiliser son propre répertoire cgi-bin.

Comme il n'y a pas de package fcgiwrap pour CentOS 6.2, nous devons le construire nous-mêmes. Nous installons d'abord quelques prérequis :

yum install fcgi-devel

Nous pouvons maintenant construire fcgiwrap comme suit :

cd /usr/local/src/
git clone git://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure
faire
faire installer

Ceci installe fcgiwrap dans /usr/local/sbin/fcgiwrap.

Ensuite, nous installons le paquet spawn-fcgi qui nous permet d'exécuter fcgiwrap en tant que démon :

yum install spawn-fcgi

Ouvrez /etc/sysconfig/spawn-fcgi...

vi /etc/sysconfig/spawn-fcgi

... et modifiez le fichier comme suit :

# You must set some working options before the "spawn-fcgi" service will work.
# If SOCKET points to a file, then this file is cleaned up by the init script.
#
# See spawn-fcgi(1) for all possible options.
#
# Example :
#SOCKET=/var/run/php-fcgi.sock
#OPTIONS="-u apache -g apache -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
FCGI_SOCKET=/var/run/fcgiwrap.socket
FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
FCGI_USER=apache
FCGI_GROUP=apache
FCGI_EXTRA_OPTIONS="-M 0770"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"

Ajoutez maintenant l'utilisateur nginx au groupe apache :

usermod -a -G apache nginx

Créez les liens de démarrage du système pour spawn-fcgi...

chkconfig --levels 235 spawn-fcgi on

... et démarrez-le comme suit :

/etc/init.d/spawn-fcgi start

Vous devriez maintenant trouver le socket fcgiwrap dans /var/run/fcgiwrap.socket, appartenant à l'utilisateur et au groupe apache (certains scripts, par exemple Mailman, s'attendent à être exécutés par l'utilisateur/groupe apache, c'est pourquoi nous n'exécutons pas spawn -fcgi en tant qu'utilisateur/groupe nginx, mais ajoutez à la place nginx au groupe apache).

16 Installer phpMyAdmin

Ensuite, nous installons phpMyAdmin :

yum install phpmyadmin

Ensuite, nous changeons l'authentification dans phpMyAdmin de cookie à http :

vi /usr/share/phpmyadmin/config.inc.php
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

Vous pouvez maintenant trouver phpMyAdmin dans le répertoire /usr/share/phpmyadmin/.

Après avoir installé ISPConfig 3, vous pouvez accéder à phpMyAdmin comme suit :

The ISPConfig apps vhost on port 8081 for nginx comes with a phpMyAdmin configuration, so you can use http://server1.example.com:8081/phpmyadmin or http://server1.example.com:8081/phpMyAdmin to access phpMyAdmin.

If you want to use a /phpmyadmin or /phpMyAdmin alias that you can use from your web sites, this is a bit more complicated than for Apache because nginx does not have global aliases (i.e., aliases that can be defined for all vhosts). Therefore you have to define these aliases for each vhost from which you want to access phpMyAdmin.

To do this, paste the following into the nginx Directives field on the Options tab of the web site in ISPConfig:

        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       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;
        }

If you use https instead of http for your vhost, you should add the line fastcgi_param HTTPS on; to your phpMyAdmin configuration like this:

        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_param HTTPS on; # <-- add this line
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       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;
        }

If you use both http and https for your vhost, you need to add the following section to the http {} section in /etc/nginx/nginx.conf (before any include lines) which determines if the visitor uses http or https and sets the $fastcgi_https variable (which we will use in our phpMyAdmin configuration) accordingly:

vi /etc/nginx/nginx.conf
[...]
http {
[...]
    ## Detect when HTTPS is used
    map $scheme $fastcgi_https {
      default off;
      https on;
    }
[...]
}
[...]

Don't forget to reload nginx afterwards:

/etc/init.d/nginx reload 

Then go to the nginx Directives field again, and instead of fastcgi_param HTTPS on; you add the line fastcgi_param HTTPS $fastcgi_https; so that you can use phpMyAdmin for both http and https requests:

        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_param HTTPS $fastcgi_https; # <-- add this line
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       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;
        }

17 Install Mailman

Since version 3.0.4, ISPConfig also allows you to manage (create/modify/delete) Mailman mailing lists. If you want to make use of this feature, install Mailman as follows:

yum install mailman

Before we can start Mailman, a first mailing list called mailman must be created:

/usr/lib/mailman/bin/newlist mailman

[[email protected] tmp]# /usr/lib/mailman/bin/newlist mailman
Enter the email of the person running the list: <-- admin email address, e.g. [email protected]
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:              "|/usr/lib/mailman/mail/mailman post mailman"
mailman-admin:        "|/usr/lib/mailman/mail/mailman admin mailman"
mailman-bounces:      "|/usr/lib/mailman/mail/mailman bounces mailman"
mailman-confirm:      "|/usr/lib/mailman/mail/mailman confirm mailman"
mailman-join:         "|/usr/lib/mailman/mail/mailman join mailman"
mailman-leave:        "|/usr/lib/mailman/mail/mailman leave mailman"
mailman-owner:        "|/usr/lib/mailman/mail/mailman owner mailman"
mailman-request:      "|/usr/lib/mailman/mail/mailman request mailman"
mailman-subscribe:    "|/usr/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe:  "|/usr/lib/mailman/mail/mailman unsubscribe mailman"

Hit enter to notify mailman owner... <-- ENTER

[[email protected] tmp]#

Open /etc/aliases afterwards...

vi /etc/aliases

... and add the following lines:

[...]
mailman:              "|/usr/lib/mailman/mail/mailman post mailman"
mailman-admin:        "|/usr/lib/mailman/mail/mailman admin mailman"
mailman-bounces:      "|/usr/lib/mailman/mail/mailman bounces mailman"
mailman-confirm:      "|/usr/lib/mailman/mail/mailman confirm mailman"
mailman-join:         "|/usr/lib/mailman/mail/mailman join mailman"
mailman-leave:        "|/usr/lib/mailman/mail/mailman leave mailman"
mailman-owner:        "|/usr/lib/mailman/mail/mailman owner mailman"
mailman-request:      "|/usr/lib/mailman/mail/mailman request mailman"
mailman-subscribe:    "|/usr/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe:  "|/usr/lib/mailman/mail/mailman unsubscribe mailman"

Run

newaliases

afterwards and restart Postfix:

/etc/init.d/postfix restart

Create the system startup links for Mailman and start it:

chkconfig --levels 235 mailman on
/etc/init.d/mailman start

Now we need to create this symlink to make Mailman work with ISPConfig:

cd /usr/lib/mailman/cgi-bin/
ln -s ./ mailman

If you want to use Mailman from your web sites created through ISPConfig, this is a bit more complicated than for Apache because nginx does not have global aliases (i.e., aliases that can be defined for all vhosts). Therefore you have to define these aliases for each vhost from which you want to access Mailman.

To do this, paste the following into the nginx Directives field on the Options tab of the web site in ISPConfig:

        location /cgi-bin/mailman {
               alias /usr/lib/mailman/cgi-bin;
               fastcgi_split_path_info (^/cgi-bin/mailman/[^/]*)(.*)$;
               include /etc/nginx/fastcgi_params;
               fastcgi_param SCRIPT_FILENAME /usr/lib/mailman$fastcgi_script_name;
               fastcgi_param PATH_INFO $fastcgi_path_info;
               fastcgi_param PATH_TRANSLATED /usr/lib/mailman$fastcgi_path_info;
               fastcgi_intercept_errors on;
               fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
        location /images/mailman {
               alias /usr/lib/mailman/icons;
        }
        location /pipermail {
               alias /var/lib/mailman/archives/public;
               autoindex on;
        }

This defines the alias /cgi-bin/mailman/ for your vhost, which means you can access the Mailman admin interface for a list at http:///cgi-bin/mailman/admin/, and the web page for users of a mailing list can be found at http:///cgi-bin/mailman/listinfo/.

Under http:///pipermail you can find the mailing list archives.

The Perfect Server - CentOS 6.2 x86_64 With nginx [ISPConfig 3] - Page 6

18 Install PureFTPd

PureFTPd can be installed with the following command:

yum install pure-ftpd

Then create the system startup links and start PureFTPd:

chkconfig --levels 235 pure-ftpd on
/etc/init.d/pure-ftpd start

Now we configure PureFTPd to allow FTP and TLS sessions. FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure.

OpenSSL is needed by TLS; to install OpenSSL, we simply run:

yum install openssl

Open /etc/pure-ftpd/pure-ftpd.conf...

vi /etc/pure-ftpd/pure-ftpd.conf

If you want to allow FTP and TLS sessions, set TLS to 1:

[...]
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
#     including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.
TLS                      1
[...]

In order to use TLS, we must create an SSL certificate. I create it in /etc/ssl/private/, therefore I create that directory first:

mkdir -p /etc/ssl/private/

Afterwards, we can generate the SSL certificate as follows:

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

Country Name (2 letter code) [XX]:<-- Enter your Country Name (e.g., "DE").
State or Province Name (full name) []:<-- Enter your State or Province Name.
Locality Name (eg, city) [Default City]:<-- Enter your City.
Organization Name (eg, company) [Default Company 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 or your server's hostname) []:<-- Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com").
Email Address []:<-- Enter your Email Address.

Change the permissions of the SSL certificate:

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

Finally restart PureFTPd:

 /etc/init.d/pure-ftpd restart

C'est ça. You can now try to connect using your FTP client; however, you should configure your FTP client to use TLS.

19 Install BIND

We can install BIND as follows:

yum install bind bind-utils

Next open /etc/sysconfig/named...

vi /etc/sysconfig/named

... and make sure that the ROOTDIR=/var/named/chroot line is comment out:

# BIND named process options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# Currently, you can use the following options:
#
# ROOTDIR="/var/named/chroot"  --  will run named in a chroot environment.
#                            you must set up the chroot environment
#                            (install the bind-chroot package) before
#                            doing this.
#       NOTE:
#         Those directories are automatically mounted to chroot if they are
#         empty in the ROOTDIR directory. It will simplify maintenance of your
#         chroot environment.
#          - /var/named
#          - /etc/pki/dnssec-keys
#          - /etc/named
#          - /usr/lib64/bind or /usr/lib/bind (architecture dependent)
#
#         Those files are mounted as well if target file doesn't exist in
#         chroot.
#          - /etc/named.conf
#          - /etc/rndc.conf
#          - /etc/rndc.key
#          - /etc/named.rfc1912.zones
#          - /etc/named.dnssec.keys
#          - /etc/named.iscdlv.key
#
#       Don't forget to add "$AddUnixListenSocket /var/named/chroot/dev/log"
#       line to your /etc/rsyslog.conf file. Otherwise your logging becomes
#       broken when rsyslogd daemon is restarted (due update, for example).
#
# OPTIONS="whatever"     --  These additional options will be passed to named
#                            at startup. Don't add -t here, use ROOTDIR instead.
#
# KEYTAB_FILE="/dir/file"    --  Specify named service keytab file (for GSS-TSIG)
#
# DISABLE_ZONE_CHECKING  -- By default, initscript calls named-checkzone
#                           utility for every zone to ensure all zones are
#                           valid before named starts. If you set this option
#                           to 'yes' then initscript doesn't perform those
#                           checks.

Make a backup of the existing /etc/named.conf file and create a new one as follows:

cp /etc/named.conf /etc/named.conf_bak
cat /dev/null> /etc/named.conf
vi /etc/named.conf

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { any; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };
        recursion no;
        allow-recursion { none; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "." IN {
        type hint;
        file "named.ca";
};
include "/etc/named.conf.local";

Create the file /etc/named.conf.local that is included at the end of /etc/named.conf (/etc/named.conf.local will later on get populated by ISPConfig if you create DNS zones in ISPConfig):

touch /etc/named.conf.local

Then we create the startup links and start BIND:

chkconfig --levels 235 named on
/etc/init.d/named start

20 Install Vlogger, Webalizer, And AWStats

Vlogger, webalizer, and AWStats can be installed as follows:

yum install webalizer awstats perl-DateTime-Format-HTTP perl-DateTime-Format-Builder

cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*

21 Install Jailkit

Jailkit is needed only if you want to chroot SSH users. It can be installed as follows (important:Jailkit must be installed before ISPConfig - it cannot be installed afterwards!):

cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.14.tar.gz
tar xvfz jailkit-2.14.tar.gz
cd jailkit-2.14
./configure
make
make install
cd ..
rm -rf jailkit-2.14*

22 Install fail2ban

This is optional but recommended, because the ISPConfig monitor tries to show the log:

yum install fail2ban

We must configure fail2ban to log to the log file /var/log/fail2ban.log because this is the log file that is monitored by the ISPConfig Monitor module. Open /etc/fail2ban/fail2ban.conf...

vi /etc/fail2ban/fail2ban.conf

... and comment out the logtarget =SYSLOG line and add logtarget =/var/log/fail2ban.log:

[...]
# Option:  logtarget
# Notes.:  Set the log target. This could be a file, SYSLOG, STDERR or STDOUT.
#          Only one log target can be specified.
# Values:  STDOUT STDERR SYSLOG file  Default:  /var/log/fail2ban.log
#
#logtarget = SYSLOG
logtarget = /var/log/fail2ban.log
[...]

Then create the system startup links for fail2ban and start it:

chkconfig --levels 235 fail2ban on
/etc/init.d/fail2ban start

23 Install rkhunter

rkhunter can be installed as follows:

yum install rkhunter

The Perfect Server - CentOS 6.2 x86_64 With nginx [ISPConfig 3] - Page 7

24 Install SquirrelMail

To install the SquirrelMail webmail client, run...

yum install squirrelmail

Then configure SquirrelMail:

/usr/share/squirrelmail/config/conf.pl

We must tell SquirrelMail that we are using Courier-IMAP/-POP3:

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <-- D


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others.  If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct.  This does not change everything.  There are
only a few settings that this will change.

Please select your IMAP server:
    bincimap    = Binc IMAP server
    courier     = Courier IMAP server
    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          = University of Washington's IMAP server
    gmail       = IMAP access to Google mail (Gmail) accounts

    quit        = Do not change anything
Command >> <-- courier


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others.  If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct.  This does not change everything.  There are
only a few settings that this will change.

Please select your IMAP server:
    bincimap    = Binc IMAP server
    courier     = Courier IMAP server
    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          = University of Washington's IMAP server
    gmail       = IMAP access to Google mail (Gmail) accounts

    quit        = Do not change anything
Command >> courier

              imap_server_type = courier
         default_folder_prefix = INBOX.
                  trash_folder = Trash
                   sent_folder = Sent
                  draft_folder = Drafts
            show_prefix_option = false
          default_sub_of_inbox = false
show_contain_subfolders_option = false
            optional_delimiter = .
                 delete_folder = true

Press enter to continue... <-- press ENTER


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <--S


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <--Q

One last thing we need to do is modify the file /etc/squirrelmail/config_local.php and comment out the $default_folder_prefix variable - if you don't do this, you will see the following error message in SquirrelMail after you've logged in:Query:CREATE "Sent" Reason Given:Invalid mailbox name.

vi /etc/squirrelmail/config_local.php
<?php
/**
 * Local config overrides.
 *
 * You can override the config.php settings here.
 * Don't do it unless you know what you're doing.
 * Use standard PHP syntax, see config.php for examples.
 *
 * @copyright &copy; 2002-2006 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id: config_local.php,v 1.2 2006/07/11 03:33:47 wtogami Exp $
 * @package squirrelmail
 * @subpackage config
 */
//$default_folder_prefix                = '';
?>

You can now find SquirrelMail in the /usr/share/squirrelmail/ directory.

After you have installed ISPConfig 3, you can access SquirrelMail as follows:

The ISPConfig apps vhost on port 8081 for nginx comes with a SquirrelMail configuration, so you can use http://server1.example.com:8081/squirrelmail or http://server1.example.com:8081/webmail to access SquirrelMail.

If you want to use a /webmail or /squirrelmail alias that you can use from your web sites, this is a bit more complicated than for Apache because nginx does not have global aliases (i.e., aliases that can be defined for all vhosts). Therefore you have to define these aliases for each vhost from which you want to access SquirrelMail.

To do this, paste the following into the nginx Directives field on the Options tab of the web site in ISPConfig:

        location /squirrelmail {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/squirrelmail/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       fastcgi_buffer_size 128k;
                       fastcgi_buffers 256 4k;
                       fastcgi_busy_buffers_size 256k;
                       fastcgi_temp_file_write_size 256k;
                       fastcgi_intercept_errors on;
               }
               location ~* ^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /webmail {
               rewrite ^/* /squirrelmail last;
        }

If you use https instead of http for your vhost, you should add the line fastcgi_param HTTPS on; to your SquirrelMail configuration like this:

        location /squirrelmail {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/squirrelmail/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_param HTTPS on; # <-- add this line
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       fastcgi_buffer_size 128k;
                       fastcgi_buffers 256 4k;
                       fastcgi_busy_buffers_size 256k;
                       fastcgi_temp_file_write_size 256k;
                       fastcgi_intercept_errors on;
               }
               location ~* ^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /webmail {
               rewrite ^/* /squirrelmail last;
        }

If you use both http and https for your vhost, you need to add the following section to the http {} section in /etc/nginx/nginx.conf (before any include lines) which determines if the visitor uses http or https and sets the $fastcgi_https variable (which we will use in our SquirrelMail configuration) accordingly (please note that you don't need to do this if you have added this section before, for example when you configured phpMyAdmin - see chapter 16):

vi /etc/nginx/nginx.conf
[...]
http {
[...]
    ## Detect when HTTPS is used
    map $scheme $fastcgi_https {
      default off;
      https on;
    }
[...]
}
[...]

Don't forget to reload nginx afterwards:

/etc/init.d/nginx reload 

Then go to the nginx Directives field again, and instead of fastcgi_param HTTPS on; you add the line fastcgi_param HTTPS $fastcgi_https; so that you can use SquirrelMail for both http and https requests:

        location /squirrelmail {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/squirrelmail/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_param HTTPS $fastcgi_https; # <-- add this line
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
                       fastcgi_buffer_size 128k;
                       fastcgi_buffers 256 4k;
                       fastcgi_busy_buffers_size 256k;
                       fastcgi_temp_file_write_size 256k;
                       fastcgi_intercept_errors on;
               }
               location ~* ^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /webmail {
               rewrite ^/* /squirrelmail last;
        }

25 Install ISPConfig 3

Before you start the ISPConfig installation, make sure that Apache is stopped (if it is installed - it is possible that some of your installed packages have installed Apache as a dependency without you knowing). If Apache2 is already installed on the system, stop it now...

/etc/init.d/httpd stop

... and remove Apache's system startup links:

chkconfig --del httpd

Make sure that nginx is running:

/etc/init.d/nginx restart

(If you have both Apache and nginx installed, the installer asks you which one you want to use:Apache and nginx detected. Select server to use for ISPConfig:(apache,nginx) [apache]:

Type nginx. If only Apache or nginx are installed, this is automatically detected by the installer, and no question is asked.)

Download the current ISPConfig 3 version and install it. The ISPConfig installer will configure all services like Postfix, Courier, etc. for you. A manual setup as required for ISPConfig 2 is not necessary anymore.

You now also have the possibility to let the installer create an SSL vhost for the ISPConfig control panel, so that ISPConfig can be accessed using https:// instead of http://. To achieve this, just press ENTER when you see this question:Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]:.

To install ISPConfig 3 from the latest released version, do this:

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

The next step is to run

php -q install.php

This will start the ISPConfig 3 installer:

[[email protected] install]# php -q install.php


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


>> Initial configuration

Operating System: Redhat or compatible, unknown version.

    Following will be a few questions for primary configuration so be careful.
    Default values are in [brackets] and can be accepted with .
    Tap in "quit" (without the quotes) to stop the installer.


Select language (en,de) [en]: <-- ENTER

Installation mode (standard,expert) [standard]: <-- ENTER

Full qualified hostname (FQDN) of the server, eg server1.domain.tld  [server1.example.com]: <-- ENTER

MySQL server hostname [localhost]: <-- ENTER

MySQL root username [root]: <-- ENTER

MySQL root password []: <- - yourrootsqlpassword

MySQL database to create [dbispconfig]: <-- ENTER

MySQL charset [utf8]: <-- ENTER

Apache and nginx detected. Select server to use for ISPConfig: (apache,nginx) [apache]: <-- nginx

Generating a 2048 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) [XX]: <-- ENTER
State or Province Name (full name) []: <-- ENTER
Locality Name (eg, city) [Default City]: <-- ENTER
Organization Name (eg, company) [Default Company Ltd]: <-- ENTER
Organizational Unit Name (eg, section) []: <-- ENTER
Common Name (eg, your name or your server's hostname) []: <-- ENTER
Email Address []: <-- ENTER
Configuring Jailkit
Configuring SASL
Configuring PAM
Configuring Courier
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring Pureftpd
Configuring BIND
Configuring nginx
Configuring Vlogger
Configuring Apps vhost
Configuring Bastille Firewall
Configuring Fail2ban
Installing ISPConfig
ISPConfig Port [8080]: <-- ENTER

Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <-- 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 incorporatedinto 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) [XX]: <-- ENTER
State or Province Name (full name) []: <-- ENTER
Locality Name (eg, city) [Default City]: <-- ENTER
Organization Name (eg, company) [Default Company Ltd]: <-- ENTER
Organizational Unit Name (eg, section) []: <-- ENTER
Common Name (eg, your name or your server's hostname) []: <-- ENTER
Email Address []: <-- ENTER

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <-- ENTER
An optional company name []: <-- ENTER
writing RSA key
Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab fo r getmail
Restarting services ...
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]
Stopping saslauthd:                                        [FAILED]
Starting saslauthd:                                        [  OK  ]
Shutting down amavisd: Daemon [1503] terminated by SIGTERM
                                                           [  OK  ]
amavisd stopped
Starting amavisd:                                          [  OK  ]

Stopping clamd.amavisd:                                    [  OK  ]
Starting clamd.amavisd:                                    [  OK  ]
Stopping Courier authentication services: authdaemond
Starting Courier authentication services: authdaemond
Stopping Courier- IMAP server: imap imap-ssl pop3 pop3-ssl
Starting Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Stopping Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Starting Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Stopping Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Starting Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Stopping Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Starting Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
SyntaxError: ('invalid syntax', ('/usr/lib/mailman/Mailman/mm_cfg.py', 76, 27, 'DEFAULT_SERVER_LANGUAGE = \n'))

Traceback (most recent call last):
  File "/usr/lib/mailman/bin/mailmanctl", line 109, in 
    from Mailman import mm_cfg
  File "/usr/lib/mailman/Mailman/mm_cfg.py", line 76
    DEFAULT_SERVER_LANGUAGE =
                             ^
SyntaxError: invalid syntax
Shutting down mailman:                                     [FAILED]
SyntaxErro r: ('invalid syntax', ('/usr/lib/mailman/Mailman/mm_cfg.py', 76, 27, 'DEFAULT_SERVER_LANGUAGE = \n'))

Traceback (most recent call last):
  File "/usr/lib/mailman/bin/mailmanctl", line 109, in 
    from Mailman import mm_cfg
  File "/usr/lib/mailman/Mailman/mm_cfg.py", line 76
    DEFAULT_SERVER_LANGUAGE =
                             ^
SyntaxError: invalid syntax
Starting mailman:                                          [FAILED]
Reloading php-fpm:                                         [  OK  ]
Reloading nginx:                                           [  OK  ]
Stopping pure-ftpd:                                        [  OK  ]
Starting pure-ftpd:                                        [  OK  ]
Installation completed.
[[email protected] install]#

To fix the Mailman errors you might get during the ISPConfig installation, open /usr/lib/mailman/Mailman/mm_cfg.py...

vi /usr/lib/mailman/Mailman/mm_cfg.py

... and set DEFAULT_SERVER_LANGUAGE ='en':

[...]
#-------------------------------------------------------------
# The default language for this server.
DEFAULT_SERVER_LANGUAGE = 'en'
[...]

Restart Mailman:

/etc/init.d/mailman restart 

Afterwards you can access ISPConfig 3 under http(s)://server1.example.com:8080/ or http(s)://192.168.0.100:8080/ (http or https depends on what you chose during installation). 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.

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

25.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/.

  • CentOS:http://www.centos.org/
  • ISPConfig :http://www.ispconfig.org/

About The Author

Falko Timme is the owner of Timme Hosting (ultra-fast nginx web hosting). He is the lead maintainer of HowtoForge (since 2005) and one of the core developers of ISPConfig (since 2000). He has also contributed to the O'Reilly book "Linux System Administration".


Panels
  1. Le serveur parfait - Fedora 15 x86_64 [ISPConfig 3]

  2. Le serveur parfait - CentOS 5.6 x86_64 [ISPConfig 2]

  3. Le serveur parfait - CentOS 6.1 x86_64 avec Apache2 [ISPConfig 3]

  4. Le serveur parfait - OpenSUSE 12.1 x86_64 avec Nginx [ISPConfig 3]

  5. Le serveur parfait - OpenSUSE 12.1 x86_64 avec Apache2 [ISPConfig 3]

Le serveur parfait - OpenSUSE 12.2 x86_64 (nginx, Dovecot, ISPConfig 3)

Le serveur parfait - CentOS 6.3 x86_64 (nginx, Dovecot, ISPConfig 3)

Le serveur parfait - CentOS 6.3 x86_64 (nginx, Courier, ISPConfig 3)

Le serveur parfait - CentOS 6.3 x86_64 (Apache2, Courier, ISPConfig 3)

Le serveur parfait - CentOS 6.4 x86_64 (nginx, Dovecot, ISPConfig 3)

Le serveur parfait - CentOS 7 x86_64 (nginx, Dovecot, ISPConfig 3)