nginx and django without virtualenv

470 views
Skip to first unread message

Paul Greenberg

unread,
Aug 6, 2014, 1:28:38 PM8/6/14
to django...@googlegroups.com

All,


I was running django with Apache and mod_wsgi for a while. Now, I am planning to run django without virtualenv. Although, it seems virtualenv might help.

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html


Any pointers? Performance issues?


Best Regards,
Paul Greenberg, Esq.

Law Office of Paul Greenberg
530 Main Street, Suite 102
Fort Lee, NJ 07024
E-mail: pa...@greenberg.pro
Tel:  201-402-6777
Fax:  201-301-8876
Web: http://www.greenberg.pro/
Twitter: @nymetrolaw

Collin Anderson

unread,
Aug 6, 2014, 1:38:54 PM8/6/14
to django...@googlegroups.com
Personally, in my `manage.py and `wsgi.py, I have the line:

import site

site
.addsitedir('/path/to/virtenv/lib/python2.7/site-packages')

Actually, truthfully, I've merged wsgi.py and manage.py into one manage.py)
#!/usr/bin/env python
import os
import site
import sys
sys
.dont_write_bytecode = True  # don't write .pyc files
sys.path.append(os.path.dirname(__file__))
site
.addsitedir('/path/to/virtenv/lib/python2.7/site-packages')
os
.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'


if __name__ == '__main__':  # command line
   
from django.core.management import execute_from_command_line
    execute_from_command_line
(sys.argv)
else:  # wsgi
   
from django.core.wsgi import get_wsgi_application
    application
= get_wsgi_application()


Bill Freeman

unread,
Aug 6, 2014, 1:47:42 PM8/6/14
to django-users
Performance *should* be identical.

All that virtualenv does (from the point of view of the executing python program) is to change how sys.prefix and sys.exec_prefix are set, and thus, how sys.path is calculated.

But with a vanilla sys.path, you need to be sure that django, your other dependencies, and your project are all still found.  (Installing django in a virtualenv does *NOT* also install it in the main python (actually, it's the python that mod_wsgi is linked against that counts).


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1407345736984.18318%40greenberg.pro.
For more options, visit https://groups.google.com/d/optout.

Paul Greenberg

unread,
Aug 6, 2014, 1:47:49 PM8/6/14
to django...@googlegroups.com

Collin,


I will be running it with p3.4.


How is the performance of it?



Best Regards,
Paul Greenberg, Esq.

Law Office of Paul Greenberg
530 Main Street, Suite 102
Fort Lee, NJ 07024
E-mail: pa...@greenberg.pro
Tel:  201-402-6777
Fax:  201-301-8876

Web: http://www.greenberg.pro/
Twitter: @nymetrolaw



From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Collin Anderson <cmawe...@gmail.com>
Sent: Wednesday, August 06, 2014 1:38 PM
To: django...@googlegroups.com
Subject: Re: nginx and django without virtualenv
 
--
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 http://groups.google.com/group/django-users.

Collin Anderson

unread,
Aug 6, 2014, 1:50:18 PM8/6/14
to django...@googlegroups.com
Actually, that's a good point. I always use the same python version that's linked with mod_wsgi. I don't use a virtualenv to use a different python version.

Paul Greenberg

unread,
Aug 6, 2014, 1:52:56 PM8/6/14
to django-users

Bill,


I see. However, I wanted to try uwsgi instead of mod_wsgi. I will be using nginx, not Apache.




Best Regards,
Paul Greenberg, Esq.

Law Office of Paul Greenberg
530 Main Street, Suite 102
Fort Lee, NJ 07024
E-mail: pa...@greenberg.pro
Tel:  201-402-6777
Fax:  201-301-8876

Web: http://www.greenberg.pro/
Twitter: @nymetrolaw




From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Bill Freeman <ke1...@gmail.com>
Sent: Wednesday, August 06, 2014 1:47 PM
To: django-users

Subject: Re: nginx and django without virtualenv

Bill Freeman

unread,
Aug 6, 2014, 1:54:07 PM8/6/14
to django-users
Though if he's moving to nginx, thus not mod_wsgi, I guess it doesn't matter what mod_wsgi is linked against.


On Wed, Aug 6, 2014 at 1:49 PM, Collin Anderson <cmawe...@gmail.com> wrote:
Actually, that's a good point. I always use the same python version that's linked with mod_wsgi. I don't use a virtualenv to use a different python version.

--
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 http://groups.google.com/group/django-users.

Bill Freeman

unread,
Aug 6, 2014, 1:55:55 PM8/6/14
to django-users
Right.  I thought of that later.

But virtualenv or not is still just a different sys.path, and you still have to have your stuff installed in the correct python.
Reply all
Reply to author
Forward
0 new messages