vrijdag 26 december 2014

First steps - web2py on Raspberry Pi

I just got a Raspberry Pi for Xmas! Next to wild ideas about home automation I'll keep some notes on in this blog, I wanted to see if I could get web2py - a great python web framework - to work on my little box.

I tought I was lucky after finding this Ridge Solutions blog entry with Google. However, I kept on getting Invalid Request and File does not exist errors. My /var/log/apache2/error.log was full off:

[Fri Dec 26 21:58:56 2014] [error] [client 81.83.148.157] File does not exist: /var/www/web2py
[Fri Dec 26 21:59:41 2014] [error] [client 81.83.148.157] Invalid method in request \x16\x03\x01
Later on:
[Fri Dec 26 23:23:49 2014] [crit] [client 81.83.148.157] configuration error:  couldn't perform authentication. AuthType not s
et!: /web2py/
From spending a good 2hrs googling and editing apache config files, I believe the culprit is some mix-ups between Apache 2.2 and 2.4 configuration in the script.

It's finally working for me with the following:
- run the script - it will install all packages you need and put web2py in /home/www-data
- rename web2py in /etc/apache2/sites-available to web2py.conf (ref)
- symlink to web2py.conf in /etc/apache2/sites-available from /etc/apache2/sites-enabled/web2py
- edit web2py.conf:
  • Servername should be your IP address, e.g. ServerName xx.yy.zz.ww
  • Fix any references to /users/www-data to say /home/www-data
  • Anywhere where it says 'Require all denied', comment it out (#) and replace with (ref)
    Order deny,allow
    Deny from all
  • Anywhere where it says 'Require all granted', comment it out (#) and replace with
    Order allow,deny
    Allow from all
  • Replace the AliasMatch regexp by:
    AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) /home/www-data/web2py/applications/$1/static/$2
  • Comment out the CustomLog and ErrorLog entries - they are not needed as far as I know (logs will just go in default logs) and they caused apache to fail at restart as those folders didn't exist
If you just want to run web2py without apache, check this link - this worked straightaway before I started playing with apache.

I'm not sure this is the 100% correct way of doing it, but it worked for me!

Hope this helps anyone else who just got a Raspberry Pi for Xmas :)

Geen opmerkingen:

Een reactie posten