Does anyone know how to use mod_wsgi with multiple virtualhosts? I have 2 domains: project1.uni.edu project2.uni.edu
And I want to be able to omit the project names from the URL path, as such: http://project1.uni.edu/ -> http://project1.uni.edu/project1/default/index http://project2.uni.edu/ -> http://project2.uni.edu/project2/default/index It is IMPORTANT that the project name does not HAVE TO show up after in the URL path after the domain at all, because there are a lot of "legacy" links circulated before the web2py app was even written. Both domains are FQDNs -- I don't have access to uni.edu zones or any configuration like that. Both DNs point to the same server, where I have two virtualhosts (defined below). Also, just to make things fun, soon we will have sub1.project2.uni.edu, sub2.project2.uni.edu, etc. Project1 will not branch anymore. The thing is, for project1, I set web2py up to not have to include the app name, since it's called project1 as well. Furthermore, both projects must be able to use mod_user to show websites of users belonging to the projects (meaning they are different user directories). They also both have AWStats running (hence the WSGIScriptAliasMatch below). Now, my question (apologies to G. Dumpleton for my inability to understand) is about the WSGI ProcessGroup/ApplicationGroup settings. As I understand it, if I want to use two virtualhosts with one instance of web2py over mod_wsgi, I must define the WSGIDaemonProcess outside of the virtualhosts, and use WSGIProcessGroup with the name I defined in WSGIDaemonProcess. Or I could define two separate WSGIDaemonProcesses within the vhosts, but give them unique names. Does anyone know the ramifications of choosing 1 method over the other? My other question is about the WSGIApplicationGroup setting -- I see I can set it to %{GLOBAL}, %{SERVER}, %{RESOURCE} or %{ENV:var}. Does anyone know if setting both to %GLOBAL is ok? Or should I use %{RESOURCE} to keep them from executing in the same interpreter (or process? I'm admittedly ill-informed about these settings...). Is this setting affected by my choice of single vs multiple WSGIDaemonProcess definitions? Currently my conf files are as such: <Virtualhost *:80> ServerName project1.uni.edu WSGIDaemonProcess web2py user=www-user group=www-group processes=3 threads=5 \ display-name=%{GROUP} WSGIProcessGroup web2py WSGIApplicationGroup %{GLOBAL} WSGIScriptAliasMatch ^(/([^~].*|awstats.*)?)$ /var/www/web2py/wsgihandler.py$1 #... more stuff including web2py-static via apache, locking admin, user_dirs, awstats conf, etc... </Virtualhost> <VirtualHost *:80> ServerName project2.uni.edu WSGIDaemonProcess project2 user=www-user group=www-group processes=3 threads=5 \ display-name=%{GROUP} WSGIProcessGroup project2 WSGIApplicationGroup %{RESOURCE} WSGIScriptAliasMatch ^(/([^~].*|awstats.*)?)$ /var/www/web2py/wsgihandler.py$1 #... more stuff including web2py-static via apache, locking admin, user_dirs, awstats conf, etc... </Virtualhost> I want to change the project1 AppGroup to be RESOURCE as well to see if that has the desired effect, but I cannot do that at the moment since proejct1 is in production. LAST question: If I were to redo this configuration file to sit in a single vhost (forgetting about the mod_user/awstats for now), would the "default_application = project1" setting totally screw me on project2 URLs? If so, are there any severe disadvantages to having two separate instances of web2py ... or even better, is it possible to specify the application based on the request host? perhaps in the app-specific routes file something like: routers = dict( BASE = dict(default_application='project1' if request.env.http_host == 'project1.uni.edu' else 'project2'), ) I guess I'm not sure if the "routers" can be set from within an application, or if that will royally hose things. well, thanks in advance to anyone who responds! -Abraham On Sunday, October 17, 2010 5:21:21 PM UTC-5, Tom A wrote: > > I know this has been asked before but I've been unable to find a clear > answer. (Apologies to Graham Dumpleton who must have answered this kind of > question many times for Django etc but I can't work out how to do it for > web2py) > > I have a Debian server set up and running web2py with mod_wsgi using the > instructions in the book. All works great. > > The file /etc/apache2/sites-available/default has the virtualhost > directives as shown in the book. So at the moment any request to the server > simply shows the welcome app. > > I have 3 domain names which resolve to the IP address of the server: > > - domain1.com > - domain2.com > - domain3.com > > I have a web2py application for each of these. They are in > /var/www/web2py/applications/domain1 etc. > > So now I want to create 3 files in /etc/apache2/sites-available that will > get apache to serve up the appropriate application for each domain. > > The key is that it should not require another instance of web2py for each > application. > > Can someone suggest how the virtualhost files should look please? Many > thanks in advance. >