JAWstats sous Apache

De EjnTricks

Hand-icon.png Votre avis

Nobody voted on this yet

 You need to enable JavaScript to vote


Apache 2.2.X

Une fois déployée sur le serveur, il faut exposé JAWstats sur un serveur d'application. L'objectif de cet article est de détailler la configuration du serveur Apache pour servir cette application.

L'application va être déployée sur la même instance que Awstats, entraînant la modification du fichier de déclaration. La mise en place est simple et nécessite uniquement la déclaration d'un alias.

<VirtualHost *:80>
        ServerAdmin ejouvin@free.fr
        ServerName www.stats.jouvinio.net
        DocumentRoot /var/www/stats
        DirectoryIndex index.php index.htm index.html

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/stats>
                Options Indexes FollowSymLinks Multiviews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error_stats.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access_stats.log combined

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Multiviews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        #Alias /awstatsclasses "/usr/share/awstats/classes/"
        #Alias /awstatscss "/usr/share/awstats/css/"
        Alias /awstats-icon "/usr/share/awstats/icon/"

        ScriptAlias /awstats /usr/lib/cgi-bin/awstats.pl

        Alias /jawstats /var/opt/jawstats
        <Directory /var/opt/jawstats/>
                Options +FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

Un problème a été rencontré lors de l'installation, suite à une erreur de manipulation. Si les messages suivants apparaissent dans la log d'erreur de Apache, soit /var/log/apache2/error_stats.log pour ce site:

(13)Permission denied: /var/opt/jawstats/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable (13)Permission denied: /var/opt/jawstats/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

En fait, cela se produit quand le compte d'exécution du server ne peut accéder aux répertoires. Il se trouvait que les permissions ne donnait pas le droit d'exécution sur le répertoire racine et ses sous répertoires. Il faut bien s'assurer d'avoir les permissions suivantes, dans le cas où le compte d'exécution est www-data.

drwxr-x---  6 www-data www-data  4096 2012-03-09 01:16 ./
drwxr-xr-x 23 root     root      4096 2012-03-08 23:40 ../
-rw-r-----  1 www-data www-data 22903 2012-03-08 23:52 clsAWStats.php
-rw-r-----  1 www-data www-data   963 2012-03-08 23:52 config.dist.php
-rw-r-----  1 www-data www-data  1053 2012-03-09 00:06 config.php
-rw-r-----  1 www-data www-data 17766 2012-03-08 23:52 index.php
drwxr-x---  2 www-data www-data  4096 2012-03-08 23:47 js/
drwxr-x---  2 www-data www-data  4096 2012-03-08 23:49 languages/
-rw-r-----  1 www-data www-data    83 2009-01-23 00:50 readme.txt
drwxr-x---  2 www-data www-data  4096 2008-08-04 21:53 swf/
drwxr-x---  3 www-data www-data  4096 2008-08-04 21:53 themes/
-rw-r-----  1 www-data www-data  4358 2012-03-08 23:52 xml_history.php
-rw-r-----  1 www-data www-data  1890 2012-03-08 23:52 xml_pages.php
-rw-r-----  1 www-data www-data  2278 2012-03-08 23:52 xml_stats.php
-rw-r-----  1 www-data www-data  2314 2012-03-08 23:52 xml_update.php


Apache 2.4.X

Lors d'une mise à jour du serveur Ubuntu, Apache a été mis à jour en version 2.4.6. Cependant, l'impact est assez conséquent, car il y a eu une refonte de la gestion des droits d'accès. Des messages d'erreurs étant constatés dans les logs de Apache:

[Thu Dec 26 13:31:16.122239 2013] [authz_core:error] [pid 8080] [client 82.230.154.123:49448] AH01630: client denied by server configuration: /var/opt/jawstats

La configuration a donc été modifiée afin d'être de nouveau opérationnelle:

<VirtualHost *:80>
        ServerAdmin ejouvin@free.fr
        ServerName www.stats.jouvinio.net
        DocumentRoot /var/www/stats
        DirectoryIndex index.php index.htm index.html

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/stats>
                Options Indexes FollowSymLinks Multiviews
                AllowOverride None
                # Old configuration for APACHE 2.2
                # Order allow,deny
                # allow from all
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error_stats.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access_stats.log combined

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Multiviews +SymLinksIfOwnerMatch
                # Old configuration for APACHE 2.2
                # Order allow,deny
                # allow from all
                Require all granted
        </Directory>

        #Alias /awstatsclasses "/usr/share/awstats/classes/"
        #Alias /awstatscss "/usr/share/awstats/css/"
        Alias /awstats-icon "/usr/share/awstats/icon/"

        ScriptAlias /awstats /usr/lib/cgi-bin/awstats.pl

        Alias /jawstats /var/opt/jawstats
        <Directory /var/opt/jawstats/>
                Options +FollowSymLinks
                AllowOverride All
                # Old configuration for APACHE 2.2
                # Order allow,deny
                # allow from all
                Require all granted
        </Directory>

</VirtualHost>