Web2py Turnkey Appliance
The web2py Turnkey Linux appliance is a great way to quickly develop & deploy web2py applications into production. It is free, 100% open source and can be deployed to bare-metal, on virtual machines or into the cloud on Amazon Web Services using Turnkey Hub. It shares benefits from both the appliance world and the custom server world. While it is a small, light-weight, pre-built, easy-to-maintain well supported appliance with controlled security updates, you can still look under the hood where you’ll find a Ubuntu Server core which is useful for those times when you need additional packages, customization or when just want to understand more about what makes the appliance tick. It comes prepackaged and pre-configured with web2py, Apache, WSGI, SSL, Mysql, iPython, SFTP, SSH, Postfix, Webmin, Turnkey start-up scripts and the Turnkey configuration console. However, as good as this all sounds you’re likely to encounter a few issues along the way. The goal of this post is to help you painlessly navigate through those items.
Item #1: Web2py Version Upgrade
The first problem you might run into is that version 12 of the Turnkey appliance is running version 1.99.7 of web2py. Not a big deal right? Just click on button under version “check for upgrades” on the web2py admin page and wah la!!! Well not quite … in 1.99.7 the version parser had an issue that was fixed in later releases. If you click on the check for upgrades button in version 1.99.7 you won’t be notified of an error, you won’t be able to upgrade from the web2py admin front-end and you’ll find a corresponding ticket if you click on the errors button under the admin application.
TypeError: not all arguments converted during string formatting.
Don’t panic! There is a quick & easy work-around, just SSH into the web2py appliance and
edit line 113 in /var/www/web2py/applications/admin/controllers/default.py
so that “version_number” is wrapped with repr() — that way the tuple can be displayed as a string …
return sp_button(URL('upgrade_web2py'), T('upgrade now to %s') % repr(version_number))
Save the change and restart Apache …
Now try clicking on the check for new upgrades button and this time you should see an upgrade button appear once it is done. After clicking on the upgrade button it should upgrade you to the latest stable version of web2py and you’ll be good to go. There are some significant changes in web2py since 1.99.7 so I highly recommend upgrading.
Item #2: Creating a New Web2py Application
Another issue you may run into is that whenever you try to create an application from the web2py admin console a message will flash
unable to create application "your-application" (it may exist already)
This is most likely caused because the appliance was built by installing the web2py source from the trunk source which does not include welcome.w2p. No problem, there is an easy fix for this too, just download a copy of the latest stable web2py release and just transfer (i.e. SCP or SFTP) the welcome web2py.w2p plugin located in the web2py root directory to the Turnkey appliance and into the /var/www/web2py directory. Now try creating a new application from the web admin console, presto!
Item #3: Setting the Date & Time
When you start using web2py you may find that your timestamps and/or database application dates are off… easy…
apt-get install webmin-time /etc/init.d/webmin start
Now access webmin http://your-ipaddress:12321 and you should see a clock icon. Click on it and set the current time, your timezone if desired and ntp servers (i.e. ntp.ubuntu.com pool.ntp.org)
Item #4: Developing Behind a Proxy Server (optional)
If you’re connected to the Internet via a proxy you can add the following line to
… of course replace server & port with the appropriate values.