Serving 2 django sites with the same code
I'm serving a django site with apache and wsgi using an apache config as follow:
Alias /media/ /var/www/media/
Alias /files/ /var/www/files/
WSGIDaemonProcess fc processes=5 threads=5 display-name=%{GLOBAL}
WSGIProcessGroup fc
WSGIScriptAlias / /home/path/to/django.wsgi
The app is served in the root directory of the host. I'd like now to change this so I can serve it at http://host/app1 and anoth开发者_C百科er one, with a different django setting, at http://host/app2
How can I change the config to do this?
Thanks
You'll need a set of WSGI*
directives for each project. That second parameter to WSGIScriptAlias
tells Apache where the project lives in the tree; WSGI removes this prefix before the URL is passed to Django's URL resolver.
For example:
WSGIDaemonProcess app1 threads=15
WSGIScriptAlias /app1 /var/www/django_project1/django.wsgi
<Location /app1>
WSGIProcessGroup app1
</Location>
WSGIDaemonProcess app2 threads=15
WSGIScriptAlias /app2 /var/www/django_project2/django.wsgi
<Location /app2>
WSGIProcessGroup app2
</Location>
I haven't tried to optimize this; there may be a better way. But this should get you running.
You may try to make other folder with second settings.py
and create symbolic links to your apps, locales, static, templates, urls.py etc.
I have multiple projects using same apps so I've put them in standalone folder which i added to python path. I also use same database for both sites, but i have different SITE_ID so i can specify wchich site i want to have my content. This way i can have totally different websites using different templates, styles and images having the same content. If JS scripts are the same on both sites i create a symlink.
精彩评论