Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i've got two web apps. One was developed using Django 1.0 and the other using Django 1.4. How can I run both apps in the same apache2 server using two versions of django? Somebody told me something about virtualenv ... I'm using mod_wsgi.

Thanks

share|improve this question
    
wsgi? <!-- pointless commentary for SF length reqmts --> –  Mike Pennington Aug 3 '12 at 14:48

2 Answers 2

up vote 3 down vote accepted

You should definitely go with virtualenv.

This is how you can check if you already have virtualenv installed:

$ virtualenv --version

If you don't have virtualenv installed, you can install it like this:

$ pip install virtualenv

If that gives you an error, you probably don't have pip yet. You can install it using:

$ easy_install pip

Once virtualenv is installed you can create separated virtual Python environments, one per Django installation, like this:

$ virtualenv env

I recommend running this command in the project folder of each app. If you do so, you get a folder called 'env' which will contain the virtual Python environment. Every time you want to start working with the virtual environment you can issue this command:

$ source env/bin/activate

Your prompt should indicate that you are running the environment by looking something like this:

(env)$

You can leave the virtualenv by typing:

(env)$ deactivate

If you have come this far you can start installing environment-specific versions of Python packages like this (in an activated environment):

(env)$ pip install Django==1.0

This will install Django version 1.0 inside the current virtual environment. You can see if it worked by issuing:

(env)$ pip freeze

This should result in something like:

Django==1.0-final
wsgiref==0.1.2

You can now deactivate this environment, activate the other environment, and install Django 1.4 like this:

(env)$ pip install Django==1.4

Hope this helps!

share|improve this answer
    
Amending to this, in your WSGIDaemonProcess line, you add a python-path=/path/to/virtualenv/lib/python2.x/site-packages to make this work with mod_wsgi too. –  vdboor Sep 13 '12 at 12:48

Have you read any of the available documentation, including:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.