Tout d’abord, il faut installer mod_python :
# apt-get install libapache2-mod-python
Puis, on active le module python et on vérifie que le module CGI le soit bien :
# a2enmod python Module is already enabled # a2enmod cgi Module is already enabled
On modifie le fichier /var/www/index.html fourni de base, pour qu’il ressemble à ceci :
<HTML> <HEAD><TITLE>Exercice avec Python</TITLE></HEAD> <BODY> <DIV ALIGN="center"> <H2>Page Web interactive</H2> <P>Cette page est associée à un script Python</P> <FORM ACTION="cgi-bin/test.py" METHOD="post"> <INPUT TYPE="submit" NAME="send" VALUE="Exécuter le script"> </FORM> </DIV></BODY></HTML>
Ensuite, on crée le script python qui fait un simple print :
#! /usr/bin/env python # -*- coding: utf-8 -*- # Affichage d'un formulaire HTML simplifié : print "Content-Type: text/html" print """ <H3><FONT COLOR="Royal blue"> Page web produite par un script Python </FONT></H3> """
Maintenant, il s’agit d’activer les cgi dans la configuration de Apache, en modifiant le fichier /etc/apache2/sites-available/default :
ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AddHandler cgi-script cgi pl py Order allow,deny Allow from all </Directory>
Maintenant, nous sommes prêt pour un petit test en affichant la page index.html de notre framboise :
http://raspi/index.html
bonjour Mehdi,
j’ai suivis vos étapes pour la config de la framboise en serveur WEB CGI
mais petit soucis lorsque je me connecte a elle en HTTP :
———————————————————————————————————————–
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.22 (Debian) Server at 192.168.101.119 Port 80
———————————————————————————————————————–
avez vous une petite idee du probleme?
merci par avance
Maxime
Bonjour Maxime,
As-tu regardé tes fichiers des logs ?
As-tu bien configuré ton fichiers /etc/hostname ?
Mehdi
bonjour,
c’etait simplement une histoire de droit sur le dossier www
merci pour votre aide