I am using Home windows XP and wish to know how do i create multiple django versions on one apache service through virtual host(obviously).
I am trying to achieve that with one demonstration of python too. Must i create 1 demonstration of python for every django version or django needs only its eggs to operate, in order to have several eggs in only one python version?
That you can do something similar to this inside your httpd.conf
NameVirtualHost 0.0.0.0:80 <VirtualHost 0.0.0.0:80> ServerName myserver.com ServerAdmin email@example.com DocumentRoot "/path/to/html/root" ErrorLog "/path/to/apache-error.log" CustomLog "/path/to/apache-access.log" common Options ExecCGI FollowSymLinks MultiViews AddHandler wsgi-script .wsgi WSGIDaemonProcess djangoapp1 WSGIProcessGroup djangoapp1 WSGIScriptAlias / /path/to/djangoapp1.wsgi Alias /static /path/to/static/files DirectoryIndex index.html index.cgi AddHandler cgi-script .cgi .pl </VirtualHost> NameVirtualHost 0.0.0.0:81 <VirtualHost 0.0.0.0:81> ServerName myserver.com ServerAdmin firstname.lastname@example.org DocumentRoot "/path/to/html/root" ErrorLog "/path/to/apache-error.log" CustomLog "/path/to/apache-access.log" common Options ExecCGI FollowSymLinks MultiViews AddHandler wsgi-script .wsgi WSGIDaemonProcess djangoapp2 WSGIProcessGroup djangoapp2 WSGIScriptAlias / /path/to/djangoapp2.wsgi Alias /static /path/to/static/files DirectoryIndex index.html index.cgi AddHandler cgi-script .cgi .pl </VirtualHost>
After which, inside your djangoapp1.wsgi/djangoapp2.wsgi script you are able to define the various django versions and programs:
#!/usr/bin/python import os import sys sys.path.append('') sys.path.append('/path/to/python2.7/site-packages') sys.path.append('/path/to/python2.7/dist-packages/Django-1.3-py2.7.egg ') ... etc ... sys.path.append('/path/to/djangoapp1/src') os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoapp1.settings' os.environ['PYTHON_EGG_CACHE'] = '/tmp' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
put django source anywhere you would like and by hand specify road to django source inside your
import os os.path.insert(0, 'path-to-django-source');
You may also use virtualenv. Virtualenv fixes pathways for console applications instantly, but also for
wsgi.py you've still got to create lower path's by hand.
- donwloads django
- download other modules
- produces wsgi.py at
- produces manage.py at
All this is accomplished having a single config file
buildout.cfg- here you list your modules along with other configurations, and you operate a command:
However buildout is probably not a great choice for those who have tight due dates because you will see things you will need find out about it but when you are wanting to do more python applications I certainly recommend giving it a go.
Here are a few good examples for django+buildout setup:
An update for your comment
You can't install two django versions system wide.
You skill though is either:
Don't install django, just drop the
django-base/djangofolder to your project path. You'll have to compile the internationalization files by hand (if you are using i18n):
cd django\conf python ..\..\manage.py compilemessages
Or, install django with
python setup.py install, but use extra arguments to alter installation destination. Python documentation covers few different methods.