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
- Posted by tru3n0 at 02:51 pm
- Permalink for this entry
- Filed under: Apache
- RSS comments feed of this entry
- TrackBack URI
[...] http://tru3n0.com/index.php/2007/10/18/instalar-apache2-mod_python-en-debian/ [...]
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
Genial, muchas gracias por el apunte Le Funes, ya está cambiado. Saludos!