Servidor web Apache
la configuracion del servidor Apache esta en /etc/apache2/apache2.conf
Los archivos del sitio estan en /var/www
cambiar esta carpeta al grupo www-data con permiso lectura y escritura.
poner tu usuario en el grupo www-data
Para poder ejecutar scripts Python, es necesario habilitar el módulo mod_cgi
sudo a2enmod cgid
habilitar cgi
dentro del archivo ‘apache2.conf’
dentro de la etiqueta <Directory /var/www/> agregar:
<Directory /var/www/>
Options +ExecCGI
AddHandler cgi-script .py
</Directory>
sudo systemctl restart apache2
$ sudo service apache2 restart
para que surtan efecto los cambios realizados, reiniciar el servidor Apache
modpython.org is an Apache module that embeds the Python interpreter
Si ya tenemos python y apache corriendo (en linux debian)
apt-get install libapache2-mod-wsgi
como-ejecutar-scripts-de-python-con-apache-y-mod-wsgi
archivo /var/www/html/algo.py def application(environ,start_response): html = '<html>\n' \ '<body>\n' \ '<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \ 'Welcome to mod_wsgi Test Page\n' \ '</div>\n' \ '</body>\n' \ '</html>\n' status = '200 OK' response_header = [('Content-type','text/html')] start_response(status,response_header) return [html]
chown www-data:www-data /var/www/html/algo.py
para cambiar el dueño del archivo