installing django mod_wsgi and apache on freeBSD

Now will make django handeling related changes in config file for virtual host. Following config files works for me

<VirtualHost *:80>
    ServerName <SERVER_NAME>

    DirectoryIndex index.html
    DocumentRoot <PATH TO YOUR DJANGO APP>

    <Directory PATH TO YOUR DJANGO APP>
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias / /<PATH TO YOUR DJANGO APP>/django.wsgi

    <Directory PATH TO YOUR DJANGO APP>
      Options ExecCGI
      AddHandler wsgi-script .wsgi

      <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
      </Limit>
      <LimitExcept GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
      </LimitExcept>

    </Directory>

    Alias /media/ "<PATH TO YOUR DJANGO SRC>/trunk/django/contrib/admin/media/"
    <Directory "<PATH TO YOUR DJANGO SRC>/trunk/django/contrib/admin/media">
    Order allow,deny
    Options Indexes
    Allow from all
    IndexOptions FancyIndexing
    </Directory>

    ErrorLog /var/log/<SERVER_NAME>-error_log
    CustomLog /var/log/<SERVER_NAME>-access_log common

</VirtualHost>

Now please create wsgi hander script as

import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')

os.environ['DJANGO_SETTINGS_MODULE'] = 'APP_NAME.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Categories