URL: https://linuxfr.org/forums/programmation-python/posts/deployer-une-application-django-avec-apache-et-mod_wsgi Title: Déployer une application Django avec apache et mod_wsgi Authors: rockn Date: 2016年12月10日T16:17:51+01:00 License: CC By-SA Tags: apache2, mod_wsgi, 3d, ubuntu, django, python et freecad Score: 0 Bonjour à tous, j'ai développé une application Django qui permet de voir et convertir des modèles 3D dans différents formats. L'application se sert de FreeCAD et quelques autre librairies ( python-collada (*.dae), ifcopenshell (*.ifc) ). Le code source est sur https://framagit.org/freecad-france/FreeCADxConvert J'ai développé l'application sur un serveur distant sur Ubuntu 16.04 et la version de Django est celle proposé par les dépôts d'Ubuntu (donc Django version 1.8.7 et python version 2.7.12). Ça fonctionne plutôt bien avec le serveur de développement mais j'ai un problème pour déployer mon application avec apache ( version 2.4.18 ) et mod_wsgi (version 4.3.0). Pour formuler autrement, lorsque j’exécute la commande suivante avec mon user "normal" python manage.py runserver 0.0.0.0:9500 L'application est bien accessible et pleinement fonctionnelle à l'adresse freecad-france.com:9500 Pour déployer voilà ce que je fais : Je clone le code source dans /var/www/html/ sudo git clone https://framagit.org/freecad-france/FreeCADxConvert.git FxC J'attribue les droits nécessaire à www-data pour ce dossier sudo chown -R :www-data FxC Je modifie le fichier settings.py et je passe l'option DEBUG à False Je lance la commande : sudo python manage.py migrate Ensuite je créé le fichier vhost (fxc.conf) pour apache ( dans /etc/apache2/site-available ) : ServerName fxc.freecad-france.com ServerAlias www.fxc.freecad-france.com ServerAdmin contact@freecad-france.com DocumentRoot /var/www/html/FxC ErrorLog ${APACHE_LOG_DIR}/error-django.log CustomLog ${APACHE_LOG_DIR}/access-django.log combined #Django conf Alias /static/ /var/www/html/FxC/appFxC/static/ Alias /media/ /var/www/html/FxC/FxC/media/ WSGIDaemonProcess daemon-fxc user=www-data group=www-data WSGIProcessGroup daemon-fxc WSGIScriptAlias / /var/www/html/FxC/FxC/wsgi.py Order deny,allow Allow from all SetHandler None J'ai écrit le vhost à partir de divers exemples trouvé sur le net. Et pour finir j'active le vhost et je relance apache: sudo a2ensite fxc sudo systemctl restart apache2 Maintenant si je tente d'accéder à fxc.freecad-france.com et bien... le comportement est aléatoire :/ Une fois ou deux ça à marché un peu, j'accède à la page index mais ça bug quand je tente d'uploader avec une erreur 500. Des fois ça mouline pendant plusieurs seconde pour finir sur une erreur 500 et parfois 504. error-django.log retourne :> [Sat Dec 10 15:06:10.653321 2016] [wsgi:error] [pid 7864] [client 2a01:e35:8a2d:c6b0:35af:8f1:905b:3244:51472] Timeout when reading response headers from daemon process 'daemon-fxc': /var/www/html/FxC/FxC/wsgi.py [Sat Dec 10 15:06:16.537746 2016] [wsgi:error] [pid 7815] [client 2a01:e35:8a2d:c6b0:35af:8f1:905b:3244:51484] Truncated or oversized response headers received from daemon process 'daemon-fxc': /var/www/html/FxC/FxC/wsgi.py acces-django.log retourne plusieurs ligne du genre :> ::1 - - [10/Dec/2016:15:06:40 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 (internal dummy connection)" ::1 - - [10/Dec/2016:15:06:41 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 (internal dummy connection)" Déjà merci d'avoir lu jusqu'ici :) Je recherche donc de l'aide pour déployer cette application (comme ça je pourrais en faire un journal ;)

AltStyle によって変換されたページ (->オリジナル) /