Django virtualenv deployment configuration

我只是一个虾纸丫 提交于 2019-12-12 08:11:40

问题


I recently start to use virtualenvwrapper and created

mkdir ~/.virtualenvs
mkvirtualenv example.com

Virtualenvwarpper automatical create a virtualenv named example.com under ~/.virtualenv so this is the central container for all virtualenvs. After than I installed django and some other packages via pip and my site is at

 /srv/www/example.com/public_html/

Do I have to put my site to ~/.virtualenv/example.com if not how could I use my example.com virtualenv with my site under /srv/www/example.com/public_html. Could you show me an apache mod_wsgi configuration for this deployment? Thanks


回答1:


Read:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

It may not be sufficient to use just site.addsitedir() as it doesn't deal with certain ordering issues. You are better off using the configuration directive/option provided by mod_wsgi to add them. Otherwise, if the ordering becomes an issue you will need to add code into WSGI script that reorders sys.path as necessary.




回答2:


In your WSGI script:

import site
site.addsitedir('/home/username/.virtualenvs/example.com/lib/python2.5/site-packages')

(Adjust as appropriate for your Python version, etc.)



来源:https://stackoverflow.com/questions/3462102/django-virtualenv-deployment-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!