Comment déployer l’application Django sur EC2 d’AWS

Prémisse · Ce que vous voulez réaliser

Je souhaite déployer l’application django sur EC2 d’AWS. Le serveur utilise nginx. J’essaie aussi de faire avec uWSGI. L’environnement virtuel est réalisé avec virtualenv. Je vous remercie.

Problèmes survenant · Messages d’erreur

Le processus de nginx, wsgi est en cours d’exécution, mais localhost ne peut pas exécuter l’application. Si je frappe curl, il obtiendra une erreur interne du serveur.

bûche

!!! no internal routing support, rebuild with pcre support !!! chdir() to /opt/app/apolo_api your processes number limit is 3896 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: enabled uWSGI http bound on :5001 fd 3 uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 6 Python version: 3.5.1 (default, Sep 13 2016, 18:48:37) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] Set PythonHome to /opt/app/venv/ Python main interpreter initialized at 0x225ace0 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 166112 bytes (162 KB) for 2 cores * Operational MODE: threaded * added /opt/app/apolo_api/api/ to pythonpath. unable to load app 0 (mountpoint='') (callable not found or import error) * no app loaded. going in full dynamic mode * * uWSGI is running in multiple interpreter mode * spawned uWSGI master process (pid: 22526) spawned uWSGI worker 1 (pid: 22527, cores: 2) * Stats server enabled on /tmp/uwsgi.stats.sock fd: 12 * spawned uWSGI http 1 (pid: 22528) 

Probablement

 * No app loaded. Going in full dynamic mode * 

Il semble qu’il ait cessé de démarrer de la part de.

Ce que j’ai essayé

Créez le fichier /etc/init/uwsgi_myproject.conf

 Create /etc/init/uwsgi_myproject.conf file description "uWSGI starter for myproject" start on (local-filesystems and runlevel [2345]) stop on runlevel [016] respawn exec /usr/local/bin/uwsgi /etc/init/myproject.ini 

Créez le fichier /etc/init/myproject.ini

 [uwsgi] chdir=/opt/app/myproject module='myproject.wsgi:application' socket = /tmp/uwsgi.sock env DJANGO_SETTINGS_MODULE=myproject.settings master = true uid = nginx gid = nginx http = :5001 venv = /opt/app/venv/ python-path = /opt/app/apolo_api/api/ wsgi = app:app processes = 1 threads = 2 stats = /tmp/uwsgi.stats.sock memory-report = true thunder-lock = true max-requests = 500 max-requests-delta = 30 touch-reload=/tmp/.uwsgi_reload 

Je vous remercie.