Joseph
Joseph

Reputation: 183

Multiple sites under single django code base using mod_wsgi

I am planning to have multiple site running from one Django Codebase using Apache + mod_wsgi. Could anyone please help me in achieving this.

Upvotes: 0

Views: 706

Answers (2)

Density 21.5
Density 21.5

Reputation: 1930

  • every Django project should have it's own mod.wsgi file (not necessarily called mod.wsgi, btw) which looks like :

    import os, sys
    sys.path.append('DJANGO_PATH')
    sys.path.append('DJANGO_PATH/SITEPATH')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'SITE.settings'
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

    where DJANGO_PATH is the path where all your Django projects were created, SITEPATH is the folder where your specific project resides.

  • in Apache make a virtualhost for every site that refers to their own mod.wgsi files, like :

    WSGIScriptAlias / /DJANGOPATH/SITEPATH/mod.wsgi
    

repeat for all sites.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799390

Use different settings modules.

Upvotes: 0

Related Questions