Vous êtes ici : Accueil Debian GNU/Linux Applications Web E-Mails Installer Horde Groupware Webmail Edition sur Debian

Installer Horde Groupware Webmail Edition sur Debian

Par Pierre-Yves Landuré Dernière modification 30/04/2012 15:11

Le projet Horde est constitué de plusieurs logiciels qui ensemble forment un groupware très complet. Ces logiciels sont disponibles soit séparément, soit dans le bundle Horde Groupware Webmail Edition. Bien qu'assez lourd à mettre en place, c'est l'un des meilleurs WebMail libres. Cet article vous guide lors de son installation sur Debian.

Ce guide est testé sur:

  • Debian 6.0 Squeeze

Prérequis

Ce guide nécessite un serveur MySQL disposant du script mysql-tools disponible dans le guide Installer et configurer MySQL sur Debian.

Ce guide nécessite un serveur HTTP avec support du PHP disposant du script suivant:

Ce guide nécessite le cache d'opcode PHP APC, dont l'installation est décrite dans le guide Installer le module PHP APC sur Debian.

Paramètres

Renseignez le nom de domaine où sera disponible l'application:

DOMAIN="mail.domaine-exemple.fr"

Renseignez le nom d'hôte du serveur MySQL (si vous ne savez pas de quoi il s'agit, ne modifiez pas cette valeur):

MYSQL_HOST="localhost"

Si votre serveur MySQL n'est pas local, ce guide effectuera une connexion SSH pour y créer la base de données.

Renseignez le nom du serveur IMAP:

IMAP_DOMAIN="imap.domaine-exemple.fr"

Renseignez l'adresse mél de l'utilisateur d'administration. Ce doit être un utilisateur valide du serveur IMAP:

ADMIN_MAIL="admin@domaine-exemple.fr"

Renseignez le domaine de mél par défaut:

DEFAULT_MAIL_DOMAIN="domaine-exemple.fr"

Renseignez l'adresse mél à laquelle adresser les notifications en cas de problème:

CONTACT_MAIL="contact@domaine-exemple.fr"

Installation

Installez les logiciels nécessaires:

command apt-get install php5-gd php5-mysql php5-mcrypt \
  php5-imap php5-tidy php5-cli php-pear \
memcached php5-memcache php5-geoip make php5-dev \
php5-curl php5-ldap php5-idn php5-sasl \
libssh2-php aspell aspell-en aspell-fr \
php5-imagick php-net-ldap2 libimage-exiftool-perl

Augmentez la limite mémoire de PHP pour l'application:

MEMORY_LIMIT="128M"
if [ -e "/etc/php5/conf.d/memory-limit.ini" ]; then
  CURRENT_MEMORY_LIMIT=$(command grep 'memory_limit' /etc/php5/conf.d/memory-limit.ini \
        | command cut --delimiter='=' --fields='2-' \
        | command sed -e 's/^[ \t]*//g')
  if [ "$(echo "${CURRENT_MEMORY_LIMIT}" | command sed -e 's/M$//g')" \
       -gt "$(echo "${MEMORY_LIMIT}" | command sed -e 's/M$//g')" ]; then
    MEMORY_LIMIT="${CURRENT_MEMORY_LIMIT}"
  fi
fi
echo "; Memory limit for PHP scripts.
memory_limit = ${MEMORY_LIMIT}" > "/etc/php5/conf.d/memory-limit.ini"

Augmentez la taille maximum des fichiers uploadés:

command echo "; Upload PHP configuration.
upload_max_filesize = 10M
post_max_size = 58M
" > "/etc/php5/conf.d/upload.ini"

Appliquez les paramètres PHP propres à Horde:

command echo "; PHP Horde configuration.
session.gc_divisor = 10000
session.gc_probability = 1
" > '/etc/php5/conf.d/horde.ini'

Mettez à jour PEAR:

command pear channel-update pear.php.net
command pear upgrade-all

Installez les modules optionnels de Horde:

command pear install channel://pear.php.net/HTTP_WebDAV_Server-1.0.0RC6
command pear install channel://pear.php.net/XML_Serializer-0.20.2

Installez le module PECL lzf pour réduire la taille des sessions:

command pecl install lzf

Ajoutez le à la configuration PHP:

command echo 'extension=lzf.so' \
  > '/etc/php5/conf.d/lzf.ini'

Téléchargement des sources

Ajoutez le canal Horde à la configuration de PEAR:

command pear channel-discover 'pear.horde.org'

Paramétrez le dossier d'installation de l'application:

command pear install horde/horde_role
command echo "/opt/${DOMAIN}" > '/tmp/horde-path.txt'
command pear run-scripts horde/horde_role < '/tmp/horde-path.txt'
command rm '/tmp/horde-path.txt'

Installez les sources de l'application:

command pear install -a -B horde/webmail

Installez le support des dates de vacances:

command pear install 'channel://pear.php.net/Date_Holidays-0.21.5'

Création de la base de données

Créez la base de données:

if [ "${MYSQL_HOST}" = "localhost" ]; then
  MYSQL_PARAMS=$(command mysql-tools create-domain-db "${DOMAIN}")
else
  command echo "Saisissez le mot de passe de l'utilisateur root MySQL :"
  command read PASSWORD
  MYSQL_PARAMS=$(command ssh "root@${MYSQL_HOST}" "command mysql-tools create-domain-db '${DOMAIN}' '$(command cat /etc/mailname)' '${PASSWORD}'")
fi

Récupérez les paramètres de la nouvelle base de données:

MYSQL_DB="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_DB" \
    | cut --delimiter="=" --fields="2-")"
MYSQL_USER="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_USER" \
    | cut --delimiter="=" --fields="2-")"
MYSQL_PASSWORD="$(echo "${MYSQL_PARAMS}" | command grep -e "^MYSQL_PASSWORD" \
    | cut --delimiter="=" --fields="2-")"
echo "${MYSQL_PARAMS}"

Configuration de la journalisation

Configurez Syslog pour enregistrer les messages de Horde dans un fichier dédié:

if [ -z "$(command grep 'Horde messages' '/etc/syslog-ng/syslog-ng.conf')" ]; then
command echo '
########################
# Horde messages
########################

destination d_horde { file("/var/log/horde.log"); };
filter f_horde { facility(user) and program("^HORDE$"); };
log { source(s_src); filter(f_horde); destination(d_horde); };
' >> '/etc/syslog-ng/syslog-ng.conf'
fi

Créez le fichier log pour Horde:

command touch '/var/log/horde.log'
command chown root:adm '/var/log/horde.log'
command chmod 640 '/var/log/horde.log'

Redémarrez Syslog:

/etc/init.d/syslog-ng restart

Configuration du Webmail

Créez le fichier de configuration suggérée:

echo "webmail-install suggested replies :
What database backend should we use? mysqli
Username to connect to the database as : ${MYSQL_USER}
Password : ${MYSQL_PASSWORD}" > '/tmp/horde-config'
if [ "${MYSQL_HOST}" = "localhost" ]; then
echo "How should we connect to the database? unix" >> '/tmp/horde-config'
else
echo "How should we connect to the database? tcp
Database server/host : ${MYSQL_HOST}
Port the DB is running on, if non-standard : 3306" >> '/tmp/horde-config'
fi
echo "Database name to use : ${MYSQL_DB}
Internally used charset : utf-8
Use SSL to connect to the server? 0
Certification Authority to use for SSL connections : []
Split reads to a different server? : false
Specify an existing mail user who you want to give administrator
permissions : ${ADMIN_MAIL}" >> '/tmp/horde-config'

Lancez le script d'installation du webmail:

cat '/tmp/horde-config'
command webmail-install

Supprimez le fichier contenant la configuration suggérée:

command rm '/tmp/horde-config'

Créez la configuration du serveur HTTP pour votre domaine:

command a2tools add-vhost "${DOMAIN}" "/opt/${DOMAIN}/" "All"

Forcez le HTTPS si vous utilisez un reverse proxy HTTPS vers HTTP:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// Force HTTPS
\$conf['use_ssl'] = 1;
" >> "/opt/${DOMAIN}/config/conf.local.php"

Mettez en place le rappel par email des alarmes:

command echo "# Horde Alarms
*/5 * * * *   www-data   test -x /usr/bin/horde-alarms && /usr/bin/horde-alarms" \
> "/etc/cron.d/horde-${DOMAIN}"

Mettez en place la connexion au serveur IMAP:

command mkdir --parent "/opt/${DOMAIN}/imp/config/backends.d"
command echo "<?php //  Imap server config
\$servers['imap']['hostspec'] = '${IMAP_DOMAIN}';
\$servers['imap']['hordeauth'] = 'full';
\$servers['imap']['secure'] = 'tls';
" > "/opt/${DOMAIN}/imp/config/backends.d/backends-${IMAP_DOMAIN}.php"

Mettez en place la connexion au serveur Sieve:

command mkdir --parent "/opt/${DOMAIN}/ingo/config/backends.d"
command echo "<?php //  Sieve server config
\$backends['imap']['disabled'] = true;
\$backends['sieve']['params']['hostspec'] = '${IMAP_DOMAIN}';
\$backends['sieve']['disabled'] = false;
" > "/opt/${DOMAIN}/ingo/config/backends.d/backends-${IMAP_DOMAIN}.php"

Configurez le domaine d'email par défaut, et le contact d'administration:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// default domain:
\$conf['problems']['maildomain'] = '${DEFAULT_MAIL_DOMAIN}';
\$conf['problems']['email'] = '${CONTACT_MAIL}';
" >> "/opt/${DOMAIN}/config/conf.local.php"

Configuration du client mél

Afficher en ligne les messages HTML

Activez l'affichage en ligne les messages formatés en HTML:

command mkdir --parent "/opt/${DOMAIN}/config/mime_drivers.d"
echo "<? // local MIME drivers.
\$mime_drivers['html']['inline'] = true;
" > "/opt/${DOMAIN}/config/mime_drivers.d/inline_html.php"

Configurer les dossiers par défaut

Pour utiliser les dossiers de Thunderbird:

echo "<? // Folder configs
\$_prefs['use_trash']['value'] = true;
\$_prefs['spam_folder']['value'] = Horde_String::convertCharset('Junk', 'UTF-8', 'UTF7-IMAP');
\$_prefs['move_ham_after_report']['value'] = 1;
\$_prefs['delete_spam_after_report']['value'] = 2;
" > "/opt/${DOMAIN}/imp/config/prefs.d/folders.php"

La configuration pour Outlook est différente, et n'ayant pas ce client à disposition, vous devrez la déterminer vous même.

Améliorations

Mise en place du cache

Activez l'utilisation de memcached:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// Horde memcache usage
\$conf['memcache']['hostspec'] = array('localhost');
\$conf['memcache']['port'] = array('11211');
\$conf['memcache']['weight'] = array();
\$conf['memcache']['persistent'] = true;
\$conf['memcache']['c_threshold'] = 0;
\$conf['memcache']['compression'] = true;
\$conf['memcache']['large_items'] = true;
\$conf['memcache']['enabled'] = true;
" >> "/opt/${DOMAIN}/config/conf.local.php"

Activez le cache APC:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// APC cache
\$conf['cache']['driver'] = 'Apc';
" >> "/opt/${DOMAIN}/config/conf.local.php"

Créez le cache javascript et css:

command mkdir --parent "/var/cache/horde/${DOMAIN}"
command mv "/opt/${DOMAIN}/static" "/var/cache/horde/${DOMAIN}/static"
command ln -s "/var/cache/horde/${DOMAIN}/static" "/opt/${DOMAIN}/static"
command chown -R www-data:www-data "/var/cache/horde/${DOMAIN}"

Activez le cache Javascript et CSS:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// JS cache
\$conf['cachecss'] = true;
\$conf['cachecssparams'] = array(
'driver' => 'filesystem',
'lifetime' => 86400,
'compress' => 'php'
);

// CSS cache
\$conf['cachejs'] = true;
\$conf['cachejsparams'] = array(
'driver'   => 'filesystem',
'lifetime' => 86400,
'compress' => 'php'
);

// Theme cache
\$conf['cachethemes'] = true;
\$conf['cachethemesparams'] = array(
'check'   => 'appversion',
'lifetime' => 604800,
);
" >> "/opt/${DOMAIN}/config/conf.local.php"

Traitement des images

Utilisez Imagick et exiftool pour le traitement des images:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
  || echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// Spell driver
\$conf['image']['driver'] = 'Imagick';
\$conf['exif']['driver'] = 'Exiftool';
\$conf['exif']['params'] = array(
'exiftool' => '/usr/bin/exiftool'
);
" >> "/opt/${DOMAIN}/config/conf.local.php"

Correction orthographique

Activez le correcteur d'orthographe:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
  || echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// Spell driver
\$conf['spell']['driver'] = 'aspell';
\$conf['spell']['params'] = array(
'path' => '/usr/bin/aspell'
);
" >> "/opt/${DOMAIN}/config/conf.local.php"

Gestion des pièces jointes

Pour visionner les pièces jointes directement dans le navigateur sans les télécharger, installez les outils:

command apt-get install unrtf libwpd-tools xlhtml gnumeric \
source-highlight ppthtml rpm wv enscript abiword

Configurez l'application pour les utiliser:

command mkdir --parent "/opt/${DOMAIN}/config/mime_drivers.d"
echo "<? // local MIME drivers.
\$mime_drivers['deb']['disable'] = false;
\$mime_drivers['msword']['disable'] = false;
\$mime_drivers['msexcel']['disable'] = false;
\$mime_drivers['mspowerpoint']['disable'] = false;
\$mime_drivers['rpm']['disable'] = false;
\$mime_drivers['rtf']['disable'] = false;
\$mime_drivers['wordperfect']['disable'] = false;
" > "/opt/${DOMAIN}/config/mime_drivers.d/extended_support.php"

Localisation des IPs

Téléchargez la base de données de localisation des adresses IPs:

command wget 'http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz' \
--output-document="/opt/${DOMAIN}/config/GeoIPv6.dat.gz"
command gunzip "/opt/${DOMAIN}/config/GeoIPv6.dat.gz"

Configurez l'application pour l'utiliser:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
  || echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// GeoIP country lookup
\$conf['geoip'] = array(
'datafile' => '/opt/${DOMAIN}/config/GeoIPv6.dat'
);
" >> "/opt/${DOMAIN}/config/conf.local.php"

Fortunes

Pour afficher un message du jour sur la page d'accueil, installez l'outil:

command apt-get install fortunes-fr

Configurez l'application pour l'utiliser:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// Fortune
\$conf['fortune'] = array( 'exec_path' => '/usr/games/fortune' );
" >> "/opt/${DOMAIN}/config/conf.local.php"

Chiffrement GPG

Pour utiliser le chiffrement GPG des messages, installez l'outil:

command apt-get install gnupg

Configurez Horde:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// GnuPG
\$conf['gnupg']['path'] = '/usr/bin/gpg';
" >> "/opt/${DOMAIN}/config/conf.local.php"

Chiffrement OpenSSL

Pour utiliser le chiffrement SSL des messages, installez l'outil:

command apt-get install openssl ca-certificates

Configurez Horde:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "// GnuPG
\$conf['openssl']['path'] = '/usr/bin/openssl';
\$conf['openssl']['cafile'] = '/etc/ssl/certs';
" >> "/opt/${DOMAIN}/config/conf.local.php"

Outil d'administration des sessions

Activez l'outil d'administration des sessions (dangereux):

command chown www-data '/var/lib/php5'

Autres possibilités

Horde offre de nombreuses autres possibilités parmis lesquelles:

  • Récupération de la météo sur weather.com
  • API de recherche Google
  • API de Google Maps

Explorez l'interface d'administration de Horde pour en savoir plus.

Résolution des problèmes

Journaux

Affichez les journaux de Horde avec:

command tail -n 50 -f '/var/log/horde.log'

Pour déboguer les problèmes, augmentez la verbosité des journaux:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "
\$conf['log']['priority'] = 'DEBUG';
" >> "/opt/${DOMAIN}/config/conf.local.php"

Désactivez les journaux verbeux:

command sed -i -e "/log'.*'priority/d" \
"/opt/${DOMAIN}/config/conf.local.php"

Test du système

Pour testez si votre système est correctement configuré, activez les tests:

test -e "/opt/${DOMAIN}/config/conf.local.php" \
|| echo '<?php' > "/opt/${DOMAIN}/config/conf.local.php"
command echo "
\$conf['testdisable'] = false;
" >> "/opt/${DOMAIN}/config/conf.local.php"

Visitez l'URL affichée par:

echo "http://${DOMAIN}/test.php"

Une fois les tests terminés, désactivez la fonctionnalité:

command sed -i -e "/testdisable/d" \
"/opt/${DOMAIN}/config/conf.local.php"

Réinstaller tout les paquets PEAR

Dans le cas où votre installation PEAR est cassée, voici comment réinstaller tous les paquets PEAR (très dangereux):

command pear list \
  | command cut --delimiter=" " --fields=1 \
| command egrep -v "INSTALLED|==|PACKAGE" \
| command xargs -iNAME pear install --force pear/NAME

Désinstaller Horde

Désinstallez Horde proprement avec:

command pear list -c pear.horde.org \
  | command cut --delimiter=" " --fields=1 \
| command egrep -v "INSTALLED|==|PACKAGE" \
| command tac - \
| command xargs -iNAME pear uninstall -n horde/NAME

Listez les fichiers Horde installés avec:

pear list-files horde/horde

Remerciements