Des scripts CGI pour votre serveur Web 

1 - Présentation :
Les scripts CGI vous permettrons d'implanter sur votre serveur web de nombreuses fonctionnalités :

- Moteur de recherche
- Compteurs de visites
- Statistiques
- Formulaires
- Forum de discussion
...
2 - Références :
    Bibliographie :
                HTML et la programmation de serveurs P.Chaléat D. Charnay Ed. Eyrolles
                Programmation CGI Shishir Gundavaram Ed. O'Reilly
                Apache Installation et mise en oeuvre Ben Laurie & Peter Laurie Ed. O'Reilly : Chapitre 4 - Common Gateway Interface
                Introduction à PERL Scwartz & Christiansen Ed. O'Reilly
    Ressources en ligne :
     The CGI Resources index
      Un moteur de recherche : htdig
      Un autre moteur de recherche : WebGlimpse
      Un compteur pour vos pages web : WWW Homepage Access Counter & Clock
      Un forum de discussion : Discus Free Discussion

3 - Installation du moteur de recherche 

Le system ht://Dig est un moteur de recherche et d'indexation adapté à un petit domaine ou à un site Intranet. Il est libre et sous License GNU.

3.1 - Télécharger la version courante de htdig depuis ftp://ftp.gnu.org/pub/gnu/ ou depuis le site ht://Dig
3.2 - Décompresser le fichier que vous avez téléchargé :
% tar xzf tarfile.tar.gz
Ou si vous ne possédez pas GNU tar, vous pouvez utiliser cette ligne de commande :
% gunzip -c tarfile.tar.gz | tar xf -

Exemple : vous avez décompressé votre fichier htdig-3.1.0b4.tar.gz dans le répertoire /tempo, vous obtenez l'arborescence suivante :
/tempo/htdig-3.1.0b4/
Dans le répertoire htdig-3.1.0b4 vous trouverez la documentation du système  (index.html) dans le sous-répertoire htdoc, lisez attentivement ces documents.

3.3 - Configuration :
Une fois que la distribution a été décompressée, placez vous dans le nouveau répertoire (ici /tempo/htdig-3.1.0b4/ ) et lancez le programme configure :
./configure
Après cela vous devez étider le fichier CONFIG (dans notre cas, vous le trouverez dans /tempo/htdig-3.1.0b4/ ).

3.3.1 - Modification à apporter au fichier CONFIG :
Nous supposons ici :
- que votre serveur web a pour racine /home/httpd/html
- que le répertoire CGI de votre serveur web est /home/httpd/cgi-bin
 
 
Fichier CONFIG original
Fichier CONFIG modifié
##
## CONFIG
## This file is part of ht://Dig
 

#
# These variables are set by configure
#
# This specifies the root of the directory tree to be used by ht://Dig
prefix=                 /opt/www/htdig

# This specifies the root of the directory tree to be used for programs
# installed by ht://Dig
exec_prefix=            ${prefix}

#
# Please modify the variables below to reflect your preferences.
#

#
# DEST
#
# This specifies the root of the directory tree to be used by ht://Dig
#
DEST=                  $(prefix)

#
# BIN_DIR
# Set this macro to where you want the binaries to be installed.
#
BIN_DIR=               $(exec_prefix)/bin

#
# CONFIG_DIR
# This is the directory that contains ht://Dig configuration files
#
CONFIG_DIR=            $(DEST)/conf

#
# COMMON_DIR
# This is the directory for files that can be shared between different
# databases.
#
COMMON_DIR=            $(DEST)/common

#
# DATABASE_DIR
# The default directory where the search databases will reside.
#
DATABASE_DIR=          $(DEST)/db

#
# DEFAULT_CONFIG_FILE
# This macro defines where the various programs will look for a configuration
# file.
#
DEFAULT_CONFIG_FILE=   $(CONFIG_DIR)/htdig.conf

#
# CGIBIN_DIR
# The directory where your HTTP server looks for CGI programs.  This is where
# htsearch will get installed.
#
CGIBIN_DIR=             /opt/www/cgi-bin

#
# IMAGE_DIR
# Define this to be a place that can be accessed by your web server.  This is
# where a couple of images will be placed.
#
IMAGE_DIR=              /opt/www/htdocs/htdig

#
# IMAGE_URL_PREFIX
# This is the URL to prefix the images placed in IMAGE_DIR.
#
IMAGE_URL_PREFIX=        /htdig

#
# SEARCH_DIR
# Set this to the absolute path where you want the sample search form to
# be installed.
#
SEARCH_DIR=             /opt/www/htdocs/htdig

#
# SEARCH_FORM
# Set this to the name you want to give to the search form.  This form
# will be located in the SEARCH_DIR directory.
#
SEARCH_FORM=            search.html

 

## CONFIG
##
## This file is part of ht://Dig
 

#
# These variables are set by configure
#
# La raçine de l'arborescense utilisée par ht://Dig
prefix=                 /home/httpd/htdig

# This specifies the root of the directory tree to be used for programs
# installed by ht://Dig
exec_prefix=            ${prefix}

#
# Please modify the variables below to reflect your preferences.
#

#
# DEST
#
# This specifies the root of the directory tree to be used by ht://Dig
#
DEST=                  $(prefix)

#
# BIN_DIR
# Set this macro to where you want the binaries to be installed.
#
BIN_DIR=               $(exec_prefix)/bin

#
# CONFIG_DIR
# This is the directory that contains ht://Dig configuration files
#
CONFIG_DIR=            $(DEST)/conf

#
# COMMON_DIR
# This is the directory for files that can be shared between different
# databases.
#
COMMON_DIR=            $(DEST)/common

#
# DATABASE_DIR
# The default directory where the search databases will reside.
#
DATABASE_DIR=          $(DEST)/db

#
# DEFAULT_CONFIG_FILE
# This macro defines where the various programs will look for a configuration
# file.
#
DEFAULT_CONFIG_FILE=   $(CONFIG_DIR)/htdig.conf

#
# CGIBIN_DIR
# Le répertoire ou votre serveur HTTP recherche les programmes CGI.  C'est ici que htsearch sera installé.
#
CGIBIN_DIR=             /home/httpd/cgi-bin

#
# IMAGE_DIR
# Ce répertoire doit être accessible par votre serveur web. Des images utilisées par ht://Dig sont placées ici.
#
IMAGE_DIR=              /home/httpd/html/htdig

#
# IMAGE_URL_PREFIX
# This is the URL to prefix the images placed in IMAGE_DIR.
#
IMAGE_URL_PREFIX=        /htdig

#
# SEARCH_DIR
# L'exemple de formulaire de recherche sera stocké dans ce répertoire.
#
#
SEARCH_DIR=             /home/httpd/html/htdig

#
# SEARCH_FORM
# Set this to the name you want to give to the search form.  This form
# will be located in the SEARCH_DIR directory.
#
SEARCH_FORM=            search.html

 

3.4 - Compilation :
Construisez le système avec la commande suivante :
make
3.5 - Installation :
Pour installer le logiciel, vous devez lancer
make install
3.6 - Modification du fichier htdig.conf :
Adaptez htdig à vos besoins en précisant au robot de recherche l'URL de départ.
Exemple :
- votre nom de domaine Intranet est mon.domaine.net, vous modifiez le champ start_url :
start_url:        http://mon.domaine.net/
- Vous pouvez également préciser votre e-mail au robot htdig en modifiant le champ maintainer :
maintainer :    mon.e-mail@mon.domaine.net
3.7 - Lancement du robot pour une première indexation de votre domaine Intranet :
Dans le cas de notre exemple (voir le fichier CONFIG) le fichier exécutable du robot ht://Dig est installé dans
/home/httpd/htdig/bin/
Vous lancerez donc rundig avec la commande suivante : /home/httpd/htdig/bin/rundig
Quelques temps plus tard... et ceci en fonction de la taille de votre site intranet vous obtenez le message suivant :
htmerge: Total word count : xxxxxx
htmerge: Total documents : xxxx
3.8 - Rechercher un document parmi vos nombreuses pages HTML :
A l'aide d'un butineur vous pouvez lancer une recherche à partir du formulaire search.html
exemple : http://mon.domaine.net/htdig/search.html
Vous pouvez bien entendu modifier ce formulaire en l'intégrant par exemple sur une de vos pages, n'oubliez pas également de modifier  (traduction par exemple) les fichiers html du répertoire /common pour obtenir des documents résultant de la recherche adaptés à vos besoins...
 

Retour à la page précédente
Lycée Pierre & Marie Curie Saint-Lô [Manche]
dernière mise à jour : 17-02-1999