django1.6 with uwsgi and nginx on RHEL 7

54 views
Skip to first unread message

Larry Martell

unread,
Jun 6, 2016, 12:51:47 PM6/6/16
to django...@googlegroups.com
I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
but I cannot seem to get it working on RHEL7.

I get Internal Server Error in the browser, and this in the uwsgi log:

--- no python application found, check your startup logs for errors ---
[pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
[Mon Jun 6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

I have tried everything I can think of. Where am I going wrong here?

Here are my files:

nginx config:

upstream django {
server unix:///projects/elucid/elucid.sock; # for a file socket
}

# configuration of the server
server {
# the port your site will be served on
listen 9004;
# the domain name it will serve for
server_name foo.bar.com;
charset utf-8;

# max upload size
client_max_body_size 75M; # adjust to taste

# Django media
location /media {
alias /projects/elucid/elucid/media;
}

location /static {
alias /projects/elucid/static;
}

# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /projects/elucid/elucid/uwsgi_params;
}
}

/etc/uwsgi/sites/elucid_uwsgi.ini:

# mysite_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir = /projects/elucid
# Django's wsgi file
module = elucid.wsgi
# the virtualenv (full path)
# home = /

# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /projects/elucid/elucid.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
logto = /var/log/uwsgi/error.log

/etc/systemd/system/uwsgi.service:

[Unit]
Description=uWSGI Emperor service

[Service]
ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx /run/uwsgi'
ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target

wsgi.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
application = get_wsgi_application()

Larry Martell

unread,
Jun 6, 2016, 4:46:15 PM6/6/16
to django...@googlegroups.com
I figured this out - the problem turned out to be that the RHEL 7
machine had django 1.6.0 whereas the RHEL 6 machine had 1.6.10. Once I
installed 1.6.10 on the 7 machine all was well.

Avraham Serour

unread,
Jun 6, 2016, 4:55:27 PM6/6/16
to django-users
you should use isolated virtual environments for each python project, don't install packages on the system wide python, see https://virtualenv.pypa.io/en/stable/


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY7iXZJMcwn7ZuCgMeOv9brh9HF3xgDfE1B0Z%2BN_bJfWGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Larry Martell

unread,
Jun 6, 2016, 5:03:30 PM6/6/16
to django...@googlegroups.com
In general, yes, I agree. But in this cast the machine is dedicated to
just running that one app.

Avraham Serour

unread,
Jun 7, 2016, 5:34:05 AM6/7/16
to django-users
you just ran on your first problem for not using virtualenvs, I do hope you won't run onto others, but in most cases it just means you aren't seeing the problems yet.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages