Diferencia entre revisiones de «Usuario:Lmorillas/desarrollo web servidor/flask/despliegue»
De WikiEducator
Línea 80: | Línea 80: | ||
* http://flask.pocoo.org/snippets/93/ | * http://flask.pocoo.org/snippets/93/ | ||
* http://stackoverflow.com/questions/4893432/ssl-on-apache2-with-wsgi | * http://stackoverflow.com/questions/4893432/ssl-on-apache2-with-wsgi | ||
+ | * http://www.nanotutoriales.com/como-crear-un-certificado-ssl-de-firma-propia-con-openssl-y-apache-http-server | ||
+ | |||
+ | $ sudo a2enmod ssl | ||
+ | |||
+ | <source lang="apache"> | ||
+ | <VirtualHost *:443> | ||
+ | ServerName flaskr | ||
+ | |||
+ | WSGIScriptAlias / /home/lm/tmp/flaskr/flaskr.wsgi | ||
+ | |||
+ | SSLEngine On | ||
+ | SSLCertificateFile /home/lm/tmp/flaskr/crt/server.crt | ||
+ | SSLCertificateKeyFile /home/lm/tmp/flaskr/crt/server.key | ||
+ | #SSLCertificateChainFile /path/to/sub.class1.server.ca.pem | ||
+ | |||
+ | <Directory /home/lm/tmp/flaskr> | ||
+ | WSGIProcessGroup flaskr | ||
+ | WSGIApplicationGroup %{GLOBAL} | ||
+ | WSGIScriptReloading On | ||
+ | #Order deny,allow | ||
+ | #Allow from all | ||
+ | Require all granted | ||
+ | </Directory> | ||
+ | </VirtualHost> | ||
+ | </source> | ||
Revisión de 10:38 12 dic 2013
Apache con WSGI
Documentación
* http://flask.pocoo.org/docs/deploying/mod_wsgi/ |
Pasos
Instalar mod-wsgi
$ sudo apt-get update $ sudo apt-get install libapache2-mod-wsgi
Configurar usuario
$ useradd -M flask $ usermod -s /bin/false flask $ usermod -L flask $ adduser flask www-data
lanzador.wsgi
# Si usamos virtualenv activate_this = '/ruta/al/env/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) # Si no está instalada la app: para poder importar import sys sys.path.insert(0, '/ruta/a/la/aplicacion') from <miaplicacion> import app as application
- Tiene que tener permisos de ejecución
$ chmod +x lanzador.wsgi
virtual host en apache
<VirtualHost *:80> ServerName example.com WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5 home=/var/wwww/home ... WSGIScriptAlias / /var/www/yourapplication/lanzador.wsgi <Directory /var/www/yourapplication> WSGIProcessGroup yourapplication WSGIApplicationGroup %{GLOBAL} WSGIScriptReloading On Order deny,allow Allow from all </Directory> </VirtualHost>
$ sudo a2ensite nuevo_sitio $ sudo service apache2 restart | reload
Si hay errores ...
$ tail -f /var/log/apache/error.log
con userdir
<Directory /home/*/public_html> Options Indexes FollowSymLinks MultiViews ExecCGI AddHandler wsgi-script .wsgi Order allow,deny Allow from all </Directory>
https ??
- http://www.subdimension.co.uk/2012/11/10/flask_modwsgi_ssl_oh_my.html
- http://flask.pocoo.org/snippets/93/
- http://stackoverflow.com/questions/4893432/ssl-on-apache2-with-wsgi
- http://www.nanotutoriales.com/como-crear-un-certificado-ssl-de-firma-propia-con-openssl-y-apache-http-server
$ sudo a2enmod ssl
<VirtualHost *:443> ServerName flaskr WSGIScriptAlias / /home/lm/tmp/flaskr/flaskr.wsgi SSLEngine On SSLCertificateFile /home/lm/tmp/flaskr/crt/server.crt SSLCertificateKeyFile /home/lm/tmp/flaskr/crt/server.key #SSLCertificateChainFile /path/to/sub.class1.server.ca.pem <Directory /home/lm/tmp/flaskr> WSGIProcessGroup flaskr WSGIApplicationGroup %{GLOBAL} WSGIScriptReloading On #Order deny,allow #Allow from all Require all granted </Directory> </VirtualHost>