Django-nginx-gunicorn - not working

I am trying to configure django on nginx and gunicorn with these tutorials http://senko.net/en/django-nginx-gunicorn/ and http://honza.ca/2011/05/deploying-django-with-nginx-and-gunicorn

Setup:

virtualenv --no-site-packages qlimp cd qlimp source bin/activate pip install gunicorn django django-admin.py startproject qlimp cd qlimp python manage.py runserver 0.0.0.0:8001 

Gunicorn setup is the same as here http://senko.net/en/django-nginx-gunicorn/

changes made (run.sh):

 LOGFILE=/var/log/gunicorn/qlimp.log USER=nirmal GROUP=nirmal cd /home/nirmal/qlimp/qlimp 

Upstart also matches the tutorial from the link above.

changes made:

 exec /home/nirmal/qlimp/qlimp/run.sh 

Configuring Nginx:

 server { listen 80; server_name qlimp.com; access_log /home/nirmal/qlimp/log/access.log; error_log /home/nirmal/qlimp/log/error.log; location /static { root /home/nirmal/qlimp/qlimp; } location / { proxy_pass http://127.0.0.1:8888; } 

}

Then I restarted nginx and started the gunicorn server:

 sudo /etc/init.d/nginx restart (qlimp) cd qlimp/qlimp (qlimp) gunicorn_django -D -c run.sh 

When I start the gunicorn server, I get this error:

 Failed to read config file: run.sh Traceback (most recent call last): File "/home/nirmal/qlimp/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 65, in load_config execfile(opts.config, cfg, cfg) File "run.sh", line 3 LOGFILE=/var/log/gunicorn/qlimp.log ^ SyntaxError: invalid syntax 

Can anyone guide me? Thanks!

+4
source share
2 answers

Try / etc / gunicorn.d instead of your own sh file

0
source

I am setting up a Django application with Gunicorn and Nginx on EC2

nano / etc / init / site1.conf

 description "site1 web server" start on runlevel [2345] stop on runlevel [06] respawn respawn limit 10 5 exec /home/scripts/gunicorn_runserver.sh 

and at gunicorn_runserver.sh

 #!/bin/bash set -e LOGFILE=/var/log/nginx/site1.log NUM_WORKERS=10 # user/group to run as USER=www-data GROUP=adm cd /home/projects/project_name/ # source ../../bin/activate exec gunicorn_django -w $NUM_WORKERS \ --user=$USER --group=$GROUP --log-level=error \ --log-file=$LOGFILE 2>>$LOGFILE 

Nginx conf

 upstream app_server_hana { server localhost:8000 fail_timeout=0; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://app_server_site1; break; } } 

Finally

 /etc/init.d/nginx restart service site1 start 
0
source

Source: https://habr.com/ru/post/1413383/


All Articles