Hi,
I want to deploy web2py in a way that people would be able to develop
apps and freely put them in any directory under /var/www, but they are
not allowed to access httpd.conf. (kind of like shared hosting) Also
when browsing to the root of host, it would not be web2py app.
So I came up with this:
web2py is in directory /var/www/web2py
In httpd.conf I have this configuration for web2py:
WSGIDaemonProcess web2py user=www-data group=www-data display-name=%
{GROUP}
WSGIProcessGroup web2py
<Directory /var/www/web2py>
SetHandler wsgi-script
Options ExecCGI
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
<Directory /var/www/web2py/applications/*/static/>
Order Allow,Deny
Allow from all
</Directory>
There is app1, app2 and admin applications installed in web2py. I want
them to be deployed in the following URLs:
www.myhost.com/app1
www.myhost.com/subdir/app2
www.myhost.com/admin
So I create directories like this:
/var/www/app1
/var/www/subdir/app2
/var/www/admin
In each directory I then put .htaccess file containing something like
this (example is for app2, other directories would have appropriate
directories ofcourse):
RewriteEngine On
RewriteRule ^(.*)$ /var/www/web2py/wsgihandler.py/app2/$1
(also could have redirection to serve static files straight)
Then each app would have app specific routes.py with something like
this (example is for app2, other directories would have appropriate
directories ofcourse):
routes_out = ((r'/$anything', r'/subdir/$anything'),)
If the developer wanted to move the app to some other directory, he
would just move the created directory with .htaccess and then edit the
app's routes.py to accommodate the new directory.
And if there would be a new app, it could be placed freely in any
subdirectory and have control of the routing in the application.
With this type of deployment the app developer could handle routing
and other things without server admin having to worry people fiddling
around with httpd.conf and this would minimize the need to restart the
server so often.
I probably missed some details in the setup, but I hope everyone got
the idea.
I managed to get this working on my test server, but is there reasons
why I shouldn't do this?