I am trying to use Apache and mod_wsgi to serve multiple django
sites.  The django sites are served up fine when at the root URL, but
when served from a sub-URL the portion of the the URL consumed by
Apache disappears from any links created in the django site pages.
>From reading throught the WSGI spec (http://www.wsgi.org/wsgi/
Specifications/routing_args), it appears that I need to specify the
SCRIPT_NAME environment variable, but I am not sure where I should do
that.  (The apache/django.wsgi file seemed like a logical place to set
the SCRIPT_NAME environment variable, but that seems to have no effect
on the generated URLs.)

Below is a description of my setup, and the apache and WSGI
configuration files.

- Tyler


OS: Ubuntu 9.04
django: 1.1 SVN-11733
apache: 2.2.11-2ubuntu2.3
libapache2-mod-wsgi: 2.3-1build1


#############################################
Apache configuration file (default)
#############################################
<VirtualHost *:80>
        ServerAdmin webmas...@localhost

    ###############################################################
    # Configuration for the olwidget test project
    ###############################################################
    Alias /olwidget/site_media/ "/usr/local/olwidget/trunk/olwidget/
django-olwidget/test_project/site_media/"
    <Directory "/usr/local/olwidget/trunk/olwidget/django-olwidget/
test_project/site_media/">
        Order allow,deny
        Options Indexes
        Allow from all
        IndexOptions FancyIndexing
    </Directory>

    Alias /olwidget/media/ "/usr/local/lib/python2.6/dist-packages/
django/contrib/admin/media/"
    <Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/
admin/media/">
        Order allow,deny
        Options Indexes
        Allow from all
        IndexOptions FancyIndexing
    </Directory>

    WSGIScriptAlias /olwidget /usr/local/olwidget/trunk/olwidget/
django-olwidget/test_project/apache/django.wsgi
    <Directory /usr/local/olwidget/trunk/olwidget/django-olwidget/
test_project/apache>
        Order deny,allow
        Allow from all
    </Directory>

        ###############################################################
        # Configuration for WFEIS
        ###############################################################
        Alias /wfeis/site_media/ "/usr/local/django_nasa_fire_dss/
site_media/"
        <Directory "/usr/local/django_nasa_fire_dss/site_media/">
            Order allow,deny
            Options Indexes
            Allow from all
            IndexOptions FancyIndexing
        </Directory>

        Alias /wfeis/media/ "/usr/local/lib/python2.6/dist-packages/django/
contrib/admin/media/"
        <Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/
admin/media/">
            Order allow,deny
            Options Indexes
            Allow from all
            IndexOptions FancyIndexing
        </Directory>

        WSGIScriptAlias /wfeis /usr/local/django_nasa_fire_dss/apache/
django.wsgi
        <Directory /usr/local/django_nasa_fire_dss/apache>
            Order deny,allow
            Allow from all
        </Directory>

</VirtualHost>


#############################################
Example WSGI configuration file
(/usr/local/olwidget/trunk/olwidget/django-olwidget/test_project/
apache/django.wsgi)
#############################################
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_project.settings'
os.environ['SCRIPT_NAME'] = 'olwidget'
# append the django project root directory to the python path
sys.path.append('/usr/local/olwidget/trunk/olwidget/django-olwidget')
sys.path.append('/usr/local/olwidget/trunk/olwidget/django-olwidget/
test_project')
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to