I can probably provide an answer even though you haven't replied.

RewriteEngine On
RewriteMap tolower int:tolower

RewriteRule ^/(.*)
/usr/local/django/${tolower:%{SERVER_NAME}}/apache/django.wsgi/$1
RewriteRule . - [E=APPLICATION_GROUP:${tolower:%{SERVER_NAME}}]

WSGIProcessGroup %{GLOBAL}
WSGIApplicationGroup %{ENV:APPLICATION_GROUP}

<DirectoryMatch /usr/local/django/*/apache>
Order allow,deny
Allow from all
Options ExecCGI
AddHandler wsgi-script .wsgi
</DirectoryMatch>

Bit more work required if you want static media served by same server,
more so if you want separate static media directories for each Django
site. To handle the static media directory you could probably use
VirtualDocumentRoot to specify the location of document roots for all
sites. Then add an appropriate RewriteCond to above so RewriteRule
isn't done for URLs which map to static media directories.

Another RewriteCond you might want is to check for existence of the
WSGI script file for a particular host value and if not present force
a forbidden response. This way avoids problems with getting strange
errors if request arrives with host for which there isn't yet a
configured site.

So, play with that and post back what you come up with that works, or
if you have other issues.

Graham

2009/1/5 Graham Dumpleton <[email protected]>:
> Which of the methods in that document are you trying to use,
> VirtualDocumentRoot from mod_vhost_alias or a mod_rewrite approach?
>
> Can you post example for the actual virtual host directory
> configuration you are using for document root/static files so can see
> what it needs to work in conjunction with, or have you not even looked
> at that aspect yet.
>
> Graham
>
> 2009/1/5 Fotinakis <[email protected]>:
>>
>> I am using mod_wsgi in embedded mode and attempting to make an Apache
>> configuration that will not require any VirtualHost changes to deploy
>> new Django sites (similar to the concept of dynamically configured
>> mass virtual hosting http://httpd.apache.org/docs/2.2/vhosts/mass.html
>> ). All that would be required is to create a new folder, such as /usr/
>> local/django/_SERVER_NAME_/ ... and then it will Just Work. At least,
>> that is the goal.
>>
>> I've tried many variations of the following (kind of ugly)
>> configuration options:
>>
>> # Causes the server name to be obtained from the client's Host
>> headers, instead of the ServerName directive
>> UseCanonicalName Off
>>
>> RewriteEngine On
>> # ServerName derived from a Host: header may be in any case
>> RewriteMap lowercase int:tolower
>> RewriteRule . - [E=wsgiservername:${lowercase:%{SERVER_NAME}}]
>>
>> WSGIScriptAlias / /usr/local/django/%{ENV:wsgiservername}/apache/
>> django.wsgi
>> <Directory /usr/local/django/%{ENV:wsgiservername}/apache>
>>        Order deny,allow
>>        Allow from all
>> </Directory>
>>
>> The error log always says something like:
>> Target WSGI script not found or unable to stat: /usr/local/django/%
>> {ENV:wsgiservername}
>>
>> I'm assuming then that WSGIScriptAlias doesn't parse environment
>> variables? Though, I'm probably terribly misunderstanding the order
>> that Apache follows when interpreting directives.
>>
>> Is there a way to do this with a WSGIScriptAliasMatch? The problem I
>> see is that the requested path doesn't contain the server name, so a
>> regex can't pull it out. Perhaps a RewriteRule can mangle the path and
>> put the ServerName in? :/
>>
>> WSGIScriptAliasMatch ^( **can the ServerName ever exist here?**)/ /usr/
>> local/django/$1/apache/django.wsgi
>>
>> That seems to be the cleanest way to do it, if something like that
>> would work (is there potential here for a new directive, such as
>> WSGIVirtualScriptAlias?). Any ideas would be much appreciated ...
>> thank you!
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to