Instalar apache2 + mod_python en Debian
Hechamos mano de nuestro querido apt-get y tecleamos lo siguiente:
apt-get install apache2
apt-get install libapache2-mod-python
Abrimos el fichero de configuración de nuestro sitio por defecto o del sitio en el que queramos ejecutar ficheros .py.
nano /etc/apache2/sites-available/default
Añadimos las líneas en rojo:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
# This directive allows us to have apache2’s default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/
</Directory>
Reiniciamos el servidor:
/etc/init.d/apache2 restart
Creamos un fichero de prueba en /var/www llamado test.py con el siguiente contenido:
nano /var/www/test.py
def index(req):
return “Test OK”;
Y para comprobar si todo ha ido bien abrimos http://localhost/test.py
Y ya estaría instalado
July 24th, 2008 at 9:58 am
[...] http://tru3n0.com/index.php/2007/10/18/instalar-apache2-mod_python-en-debian/ [...]
September 11th, 2008 at 3:00 pm
Muy buen post! bastante claro y directo
Una aclaración por el formateo, en el ejemplo existe un espacio delante de “return …” que no se vé:
def index(req):
return “Test OK”;
Saludos
September 11th, 2008 at 3:05 pm
Genial, muchas gracias por el apunte Le Funes, ya está cambiado. Saludos!