Virtualenv and Django in Production

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Virtualenv and Django in Production

adrian s
Hi all, I've been using virtualenv as recommended in my development environments. 

I am now migrating a project which was not using virtualenv, to another server and now
have the opportunity to use it in production.

I've spent a while googling this subject and I'm not sure what the best practice is.
Is it common to run a production django deployment with apache behind virtualenv? If so,
could anyone steer me in the proper direction for getting this setup with the wsgi file...

Or, is virtualenv best for just testing isolated environments, and running production
with the existing global space (I feel naive typing this out, so I must be wrong (: )
 as is (isn't there more overhead with virtualenv anyhow?)

I hope I made sense.

If anyone has any relevant docs that clarify this (maybe my searches stink) I'd love to read
over what there is so I may make an appropriate call.

Adrian

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Django in Production

Preston Holmes-3
How you use a virtualenv in production depends on all the parts of
your production stack.  If you are using mod_wsgi, search mod_wsgi +
virtualenv, gunicorn, etc

You might also consider one of the new "platform-as-a-service" hosting
options that basically solve this for you.

-P

On Sep 19, 10:55 pm, adrian s <[hidden email]> wrote:

> Hi all, I've been using virtualenv as recommended in my development
> environments.
>
> I am now migrating a project which was not using virtualenv, to another
> server and now
> have the opportunity to use it in production.
>
> I've spent a while googling this subject and I'm not sure what the best
> practice is.
> Is it common to run a production django deployment with apache behind
> virtualenv? If so,
> could anyone steer me in the proper direction for getting this setup with
> the wsgi file...
>
> Or, is virtualenv best for just testing isolated environments, and running
> production
> with the existing global space (I feel naive typing this out, so I must be
> wrong (: )
>  as is (isn't there more overhead with virtualenv anyhow?)
>
> I hope I made sense.
>
> If anyone has any relevant docs that clarify this (maybe my searches stink)
> I'd love to read
> over what there is so I may make an appropriate call.
>
> Adrian

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Virtualenv and Django in Production

schinckel
In reply to this post by adrian s
I use virtualenv in production. It means you can install python packages using pip without having root or sudo access on the server.

You can also isolate installs, and use no-site-packages.

I can't think of a reason not to use it.

Matt.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/BNM2owzrojoJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Django in Production

DrBloodmoney
In reply to this post by adrian s
On Tue, Sep 20, 2011 at 1:55 AM, adrian s <[hidden email]> wrote:

> Hi all, I've been using virtualenv as recommended in my development
> environments.
> I am now migrating a project which was not using virtualenv, to another
> server and now
> have the opportunity to use it in production.
> I've spent a while googling this subject and I'm not sure what the best
> practice is.
> Is it common to run a production django deployment with apache behind
> virtualenv? If so,
> could anyone steer me in the proper direction for getting this setup with
> the wsgi file...
> Or, is virtualenv best for just testing isolated environments, and running
> production
> with the existing global space (I feel naive typing this out, so I must be
> wrong (: )
>  as is (isn't there more overhead with virtualenv anyhow?)
> I hope I made sense.
> If anyone has any relevant docs that clarify this (maybe my searches stink)
> I'd love to read
> over what there is so I may make an appropriate call.
> Adrian

I run a VPS with several django apps isolated into different
virtualenvs. They are served by either uwsgi or gunicorn and reverse
proxied by nginx. There are several good guides if you google for some
of those keywords.

It is a pretty easy set-up. If you were only serving one django app,
it may be slight overkill, but it may be worth the effort to get it
set up this way so you can easily add more django applications and
have them be completely isolated from each other.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Django in Production

dm03514
In reply to this post by adrian s
Virtualenv provides you with more control over your production
environments.   We run apache/virtualenv on 10 of our production
servers.
There very well might be more overhead running through a virtualenv.
For us it is too negligible to make a difference.

We use fabric to deploy our django apps, and automatically initiate
virtualenvs, or update virtualenvs on remote servers.  I think virtual
env is great on production because it keeps all of our environments on
the same page.  ie.  If we update a python package to a newer version,
or roll it back to an older version.  All we have to do is make the
appropriate changes in our code, change the package version entry in
our bootstrap.py file and deploy through fabric, no manually managing
packages on our production servers, nice and simple

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Django in Production

Tom Evans-3
On Tue, Sep 20, 2011 at 4:35 PM, dm03514 <[hidden email]> wrote:

> Virtualenv provides you with more control over your production
> environments.   We run apache/virtualenv on 10 of our production
> servers.
> There very well might be more overhead running through a virtualenv.
> For us it is too negligible to make a difference.
>
> We use fabric to deploy our django apps, and automatically initiate
> virtualenvs, or update virtualenvs on remote servers.  I think virtual
> env is great on production because it keeps all of our environments on
> the same page.  ie.  If we update a python package to a newer version,
> or roll it back to an older version.  All we have to do is make the
> appropriate changes in our code, change the package version entry in
> our bootstrap.py file and deploy through fabric, no manually managing
> packages on our production servers, nice and simple
>

There is no more overhead in virtualenv than there is in python
itself. To understand why, you should look at how and why virtualenv
works - you are using a different python interpreter, so that python
interpreter looks in a different place than the stock interpreter.

virtualenv is entirely free magic that makes your deployments more
consistent and repeatable. Use it!

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Django in Production

Markus Gattol-2
In reply to this post by adrian s
 - it's just symlinks i.e. not more overhead
 - you won't clutter your system Python or vice versa when you up/downgrade something
 - easy to detect http://www.markus-gattol.name/ws/python.html#detect_a_virtualenv
 - if you want a production setup use e.g. gunicorn/nginx or even better uwsgi/mongrel2
 - as all the others here, I can strongly recommend using a virtualenv for production as well as for development

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/QZpISAJq0cEJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Virtualenv and Hudson/Jenkins

Tim Sawyer-6
Has anyone any instructions for using VirtualEnv with Hudson/Jenkins?

Thanks,

Tim.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Hudson/Jenkins

shadowy m
Yes, I would like to know to also.  This has been typical of my Django/Python experience.  The OP asked how and that they could not find good documentation and got several responses of why and "google it, lots of good info".

Maybe good info if you already mostly know what you are doing and code Python all the time.  You can find all the little bits and pieces but nobody ever seems to put it together in a way beginners/intermediates who are not necessarily professional coders can work with.  Django/Python has a LOOONg way to go in this respect in order to catch up with more mature technologies like PHP imho.

There is still no good consise, simple, organized info for this sort of deployment even though this thread was stared 2 years ago.  So things don't seem to have improved.

On Tuesday, September 20, 2011 12:30:41 PM UTC-7, Tim Sawyer wrote:
Has anyone any instructions for using VirtualEnv with Hudson/Jenkins?

Thanks,

Tim.

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/25528fbd-1e42-4bc5-9301-56a549d71ee9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Virtualenv and Hudson/Jenkins

Timothy W. Cook
Interesting in how you think that PHP is more mature and better
documented than Python.

Anyway, the OP asked about virtualenv with Hudson and Jenkins, not
about Django.  So maybe they asked in the wrong place.

Django running virtualenv is quite well documented.  But any Python
app runs the same under virtualenv.  That is kind of the point.  So
the first step is to learn about virtualenv.  Then install Django
inside a virtualenv.

Yes using Google is a valid answer when you want to get opinions about
two pieces of software working together.  The Django docs can't (and
shouldn't) cover all the possible combinations.

If you google those two combinations there are tutorials for them.

When I ask specific Django questions here; as a VERY much newbie.  I
get great answers and even followups when I don't understand how
something is working.

So your evaluation of the community is flawed.  Yes the docs are a
little confusing at first.  But the tutorial is awesome and you just
have to keep looking or ask a specific question.


Cheers,
Tim


On Wed, Nov 27, 2013 at 4:48 PM, shadowy m <[hidden email]> wrote:

> Yes, I would like to know to also.  This has been typical of my
> Django/Python experience.  The OP asked how and that they could not find
> good documentation and got several responses of why and "google it, lots of
> good info".
>
> Maybe good info if you already mostly know what you are doing and code
> Python all the time.  You can find all the little bits and pieces but nobody
> ever seems to put it together in a way beginners/intermediates who are not
> necessarily professional coders can work with.  Django/Python has a LOOONg
> way to go in this respect in order to catch up with more mature technologies
> like PHP imho.
>
> There is still no good consise, simple, organized info for this sort of
> deployment even though this thread was stared 2 years ago.  So things don't
> seem to have improved.
>
> On Tuesday, September 20, 2011 12:30:41 PM UTC-7, Tim Sawyer wrote:
>>
>> Has anyone any instructions for using VirtualEnv with Hudson/Jenkins?
>>
>> Thanks,
>>
>> Tim.
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> 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/25528fbd-1e42-4bc5-9301-56a549d71ee9%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/CA%2B%3DOU3UrKL6cFxc4bQFGfvcirfDANfSBvJjKJAmTLaYSEE-L1w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.