PHPPgAdmin

Par Pierre-Yves Landuré Dernière modification 09/01/2014 19:48

Autorisez l'accès à PHPPgAdmin via les pages de statuts du serveur.

Ce guide est testé sur:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Prérequis

Ce guide nécessite:

Paramètres

Renseignez le domaine d'accès aux statuts du serveur:

DOMAIN="status.domain.com"

Installation

Détectez le fichier de configuration du site de statut:

STATUS_VHOST="$(command grep -rl \
    "STATUS PAGES CONFIGURATION END" \
    '/etc/apache2/sites-available')"

Détectez le chemin d'installation utilisé:

if [ -n "${STATUS_VHOST}" ]; then
INSTALL_PATH=$(command grep "DocumentRoot" "${STATUS_VHOST}" \
| command sed -e 's/^[ \t]*//;s/[ \t]*$//' -e 's/[ \t]*[ \t]/ /g' \
| command cut --delimiter=" " --field=2)
fi

Détectez le sous-dossier utilisé:

SUB_FOLDER=""
if [ -n "${STATUS_VHOST}" -a -n "$(command grep '^[ ]*Alias ' "${STATUS_VHOST}")" ]; then
  SUB_FOLDER="$(command grep '^[ ]*Alias ' "${STATUS_VHOST}" \
| command grep "${INSTALL_PATH}" \
      | command sed -e 's/^[ \t]*//;s/[ \t]*$//' -e 's/[ \t]*[ \t]/ /g' \
      | command cut --delimiter=" " --field=2)"
fi

Ajoutez la configuration de PHPPgAdmin au domaine:

if [ -n "${STATUS_VHOST}" -a -e "/etc/apache2/conf.d/phppgadmin" ]; then
command cp '/etc/apache2/conf.d/phppgadmin' '/etc/phppgadmin/apache.conf'
command sed -i -e "/STATUS PAGES CONFIGURATION END/i\\
# PHPPgAdmin configuration.\\
Include '/etc/phppgadmin/apache.conf'\\
" "${STATUS_VHOST}"
fi

Ajoutez la configuration pour l'utilisation depuis un sous-dossier:

if [ -n "${SUB_FOLDER}" -a -e "/etc/phppgadmin/apache.conf" ]; then
command sed -i -e "/DocumentRoot/i\\
# PHPMyAdmin subfolder access.\\
Alias ${SUB_FOLDER}/phppgadmin /usr/share/phppgadmin\\
" "${STATUS_VHOST}"
fi

Vérifiez que la configuration d'Apache 2 ne contient pas d'erreurs:

command apache2ctl -t

Rechargez la configuration d'Apache 2:

/etc/init.d/apache2 force-reload

Ajoutez le lien correspondant à la page d'accueil du domaine.

if [ -e "/etc/phppgadmin/apache.conf" ]; then
command sed -i -e '/<\/ul>/i\
<li><a href="./phppgadmin">PHPPgAdmin</a></li>' \
  "${INSTALL_PATH}/index.html"
fi

Vous pouvez maintenant accéder à PHPPgAdmin.

Remarque: Si vous souhaitez désactiver l'accès à PHPPgAdmin hors du domaine d'affichage des status, utilisez:

command rm '/etc/apache2/conf.d/phppgadmin'
/etc/init.d/apache2 reload