Web2py, nginx, installation on Raspberry Pi

739 views
Skip to first unread message

Encompass solutions

unread,
Aug 24, 2014, 5:00:49 AM8/24/14
to web...@googlegroups.com
Hi,
Currently I am getting a 502 Bad Gateway Error when trying to access my web2py server running on Raspberry Pi.
I first tried the setup with the script setup-web2py-nginx-ubuntu.sh as it's nearly identical to the instructoins found here.
http://web2py.com/books/default/chapter/29/13#Nginx
After doing the script I got the 502 Bad Gateway error.
I know I am on the right server as I can see the request in the logs.
I then went through the tutorial on the website I previously mentioned and still got the error.
There were a few differences in the script.  For example web2py.ini verses web2py.xml (which is informationally the same.)

Any ideas on how to diagnose this and find the correct solution?

Paolo Valleri

unread,
Aug 24, 2014, 11:25:58 AM8/24/14
to web...@googlegroups.com
The script you mentioned is based on upstart but on the raspberry-pi the init script are handled by sysvinit.
So that, I'd say that uwsgi is not running? 
Try to run it manually:

sudo uwsgi --master --die-on-term --emperor /etc/uwsgi --logto /var/log/uwsgi/uwsgi.log

Paolo

Jason (spot) Brower

unread,
Aug 24, 2014, 2:46:21 PM8/24/14
to web2py-users

Yeah. Looks like that was it! How do I make this change permanent?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Bx_9u0iC86o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Art Aquino

unread,
Aug 24, 2014, 6:20:02 PM8/24/14
to web...@googlegroups.com
Run this script:
scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

It works on the pi. I did it yesterday and its all working.

Massimo Di Pierro

unread,
Aug 25, 2014, 11:26:16 AM8/25/14
to web...@googlegroups.com
I am having a similar problem too. When I run on Ubuntu 14.04 everything works as intended. When I run on Ubuntu 14.04.1 LTS I get "Internal server error" I only get the error with uwsgi-emperor, not if I run uwsgi manually. Same command line manual and in the emperor configuration.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Jim S

unread,
Aug 25, 2014, 11:29:58 AM8/25/14
to web...@googlegroups.com
Ubuntu 14.04.1 / nginx / uwsgi is working for me without problems.  I used the script referenced in the book to install it and it worked fine.  I don't recall doing anything special.

-Jim
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Massimo Di Pierro

unread,
Aug 25, 2014, 11:34:32 AM8/25/14
to web...@googlegroups.com
I used the same script on two different machines. I get

Ubuntu 14.04.1 LTS (from Digital Ocean Droplet) works fine
Ubuntu 14.04.1 LTS (from AWS Image) "internal server error"

In both cases these were fresh installations and the only code that run was setup-web2py-nginx-uwsgi-ubuntu.sh

Jason Brower

unread,
Aug 26, 2014, 2:00:15 AM8/26/14
to web...@googlegroups.com
As crazy as it sounds, I did run that script.  It was a fresh install from a NOOBS image.  There has got to be some different.  Just don't know what it is.
BR,
Jason Brower


On Mon, Aug 25, 2014 at 1:20 AM, Art Aquino <art...@gmail.com> wrote:
Run this script: scripts/setup-web2py-nginx-uwsgi-ubuntu.sh It works on the pi. I did it yesterday and its all working.

Paolo Valleri

unread,
Aug 26, 2014, 2:31:02 PM8/26/14
to web...@googlegroups.com
For rpi I see few alternatives:
- switch to upstart (mind that would be a big change for your operating system)
- create your own uwsgi script in /etc/init.d/ (google for it)
- place the command line a posted before in /etc/rc.local (mind to add an & at the end)
- uninstall the uwsgi installed by pip and install the one from the raspbian repository (it comes with the /etc/init.d/... script). In this case, I suggest to install uwsgi-emperor and uwsgi-plugin-python using apt-get, add the line 'plugin=python' in web2py.ini and place that file in /etc/uwsgi-emperor/vassals. 

 Paolo

Jason (spot) Brower

unread,
Aug 26, 2014, 3:09:44 PM8/26/14
to web2py-users

Thanks. I will probably try with the repos version and submit a pull request with a script for the web2py source. Also making a tool to publish to Qt cloud services. Perhaps we could add it to admin.

Ben Lawrence

unread,
May 25, 2016, 6:45:23 PM5/25/16
to web2py-users
Hi
Did you finally manage to upload the modified script for raspberry pi ?

Ben Lawrence

unread,
May 26, 2016, 1:21:18 AM5/26/16
to web2py-users
Never mind. I can just use


login as pi user (any user, not root) and enter following commands:

sudo apt-get install python-web2py
mkdir web2py
cd web2py
openssl genrsa -out ca.key 1024
openssl req -new -key ca.key -out ca.csr
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
web2py -a 'your_password' -i IP.IP.IP.IP -p 8000 -c ca.crt -k ca.key

where IP.IP.IP.IP is IP address of Raspberry network interface

Massimo Di Pierro

unread,
May 26, 2016, 4:33:06 PM5/26/16
to web2py-users
replace IP.IP.IP.IP with 0.0.0.0

Ben Lawrence

unread,
Jul 24, 2016, 12:55:15 AM7/24/16
to web2py-users


On Wednesday, May 25, 2016 at 3:45:23 PM UTC-7, Ben Lawrence wrote:
Reply all
Reply to author
Forward
0 new messages