Friday, October 14, 2011

How to install web2py on a shared host

I'm working on a project with a friend using web2py
Free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applications. Written and programmable in Python.
Official website

Now that we are ready to upload our website, we were looking for good shared host. It was not easy to find a good one. Finally we choose Site5 because it supports Python and the server is in Montreal.

Problem:
how to install web2py on a shared host ?

Solution:
I could find this website : web2py on shared hosting.
I followed the instructions from "Installing web2py".

When you do this, here is the url to see your app :
http://www.mydomain.com/web2py/mySuperApp/default/index

But what we wanted was something like that :
http://www.mydomain.com

So here are the modifications :
- move all the web2py files directly to "public_html".
Before : $HOME/public_html/web2py/web2py.py
After : $HOME/public_html/web2py.py
(it's just an example with web2py.py file, but you should move all the files!)

- edit $HOME/public_html/routes.py, your file should just contains :
routers = dict(
    BASE = dict(
  default_application='mySuperApp',
  domains={'mydomain.com' : 'mySuperApp'},
    ),
) 
*routers is a new feature of web2py. This parameter-based system first appeared in web2py version 1.92.1.
If you want to know which version of web2py you're using, just open the file $HOME/public_html/VERSION
 
And that's it ! Now you can access your application simply by using : www.mydomain.com !