Hi all,
I'm still a few days away from getting my first RPi (3+ months waiting!), but I've started hashing together the beginnings of a project on my Ubuntu system. I was wondering if anybody could comment on the speed that a RPi would handle something like this.
Basically I want to collect data from a USB serial port and dispatch that via a Python script. The data would be fed to a database using POST data and localhost URLs served up by nginx and Django's own FastCGI handler. (see https://code.djangoproject.com/wiki/DjangoAndNginx). Django would store the information into some undetermined flavor of SQL, as well as offer some views into the data (tables, stats, etc.). I doubt there would ever be two users at a time using the system.
Any insight on how it would "feel" to the user? Would the system be able to handle something like Postgre/MySQL? Also, I'm planning on stripping down the rest of the system to the bare essentials.
Thanks in advance for any thoughts!
Django and nginx
5 posts
- Posts: 15
- Joined: Fri Mar 16, 2012 7:46 pm
use sqlite, standard available in python
Save that data directly with python/sqlite (not using a post)
use nginx or better thttpd as frontend for presenting the data
that way it will only use a few MB.
try to keep it as simple as possible.....
Save that data directly with python/sqlite (not using a post)
use nginx or better thttpd as frontend for presenting the data
that way it will only use a few MB.
try to keep it as simple as possible.....
RPi forum : custom cases
Shapeways: picases
Thingiverse : 3D printer case - Pi Lego blocks
Cheap 3D printed case : http://www.raspberrypi.org/phpBB3/viewtopic.php?f=40&t=6104
Shapeways: picases
Thingiverse : 3D printer case - Pi Lego blocks
Cheap 3D printed case : http://www.raspberrypi.org/phpBB3/viewtopic.php?f=40&t=6104
- Posts: 212
- Joined: Mon Sep 05, 2011 7:49 am
So my Pi came this morning and I put together this script to get nginx and Django up and working. It's in two parts because you have to log out and back in first to make the user permissions stick.
It installs nginx, sets up /var/www with a static folder, adds the user pi to a www-pub group for editing in /var/www, and starts a Django project in /var/www/django
It's using information from the following pages: https://code.djangoproject.com/wiki/DjangoAndNginx and http://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var
By the way, this is how to get the FastCGI running in the background as a daemon: https://code.djangoproject.com/wiki/InitdScriptForLinux (I haven't gotten this part to work yet)
To make it easier on yourself, I'd put these into a text file like 1.txt and 2.txt, and run them as "sudo sh 1.txt" and "sudo sh 2.txt"
Let me know if you run into any issues. I tried this on a brand new Wheezy install, by the way.
It installs nginx, sets up /var/www with a static folder, adds the user pi to a www-pub group for editing in /var/www, and starts a Django project in /var/www/django
It's using information from the following pages: https://code.djangoproject.com/wiki/DjangoAndNginx and http://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var
By the way, this is how to get the FastCGI running in the background as a daemon: https://code.djangoproject.com/wiki/InitdScriptForLinux (I haven't gotten this part to work yet)
To make it easier on yourself, I'd put these into a text file like 1.txt and 2.txt, and run them as "sudo sh 1.txt" and "sudo sh 2.txt"
Let me know if you run into any issues. I tried this on a brand new Wheezy install, by the way.
- Code: Select all
#! /bin/sh
# get nginx
sudo apt-get update
sudo apt-get install nginx sqlite
# set up nginx
cd ~
sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/defaultoriginal
wget https://gist.github.com/gists/2968299/download
tar xzvf download
sudo cp ./gist2968299-ea7165ae2edd7dbb6e37b9388a6d1e1e7f1e520e/default /etc/nginx/sites-available/default
rm -rf download
rm -rf gist2968299-ea7165ae2edd7dbb6e37b9388a6d1e1e7f1e520e
# create user permissions for /var/www
sudo groupadd www-pub
sudo mkdir /var/www
sudo mkdir /var/www/django
sudo mkdir /var/www/static
sudo usermod -a -Gwww-pub pi
sudo chown -R root:www-pub /var/www
sudo chmod 2775 /var/www
sudo find /var/www -type d -exec chmod 2775 {} +
sudo find /var/www -type f -exec chmod 0664 {} +
sudo echo -e " " >> /etc/profile
sudo echo -e "umask 0002" >> /etc/profile
# get Django
cd ~
wget https://www.djangoproject.com/download/1.4/tarball/
tar xzvf tarball
cd Django-1.4
sudo python setup.py install
echo -e " "
echo -e " "
echo -e "import django; print('Django Version ' + django.get_version())" | python
echo -e " "
echo -e " "
echo -e "If you didn't see a python error, type 'logout' and hit enter"
echo -e " "
echo -e " "
- Code: Select all
#! /bin/sh
cd /var/www
django-admin.py startproject testsite
mv testsite django
cd django
python ./manage.py runfcgi host=127.0.0.1 port=8080
cd ~
sudo /etc/init.d/nginx restart
wget localhost
cat index.html
rm index.html
- Posts: 15
- Joined: Fri Mar 16, 2012 7:46 pm
[Couldn't edit or delete my earlier post but this is an update... now in the form of Github Gists that I can update.]
This script gets nginx and Django up and working. It's in two parts because you have to log out and back in first to make the user permissions stick.
It sets up /var/www with a static folder, adds the user pi to a www-pub group for editing in /var/www, and starts a Django project in /var/www/django
It's using information from the following pages: https://code.djangoproject.com/wiki/DjangoAndNginx and http://serverfault.com/questions/6895/w ... ata-in-var
By the way, this is how to get the FastCGI running in the background as a daemon: https://code.djangoproject.com/wiki/InitdScriptForLinux (I haven't gotten this part to work yet)
Note: You're going to have to tweak your nginx settings depending on how you want your server set up, this just gets it up and started with the bare minimum setup. See http://wiki.nginx.org/DjangoFastCGI and http://stackoverflow.com/questions/6051 ... for-django
To make it easier on yourself, I'd put these into a text file like part1.sh and part2.sh, and run them as "sudo sh part1.sh" and "sudo sh part2.sh"
Let me know if you run into any issues. I tried this on a brand new Wheezy install, by the way.
(Fixed the FastCGI parameters that get passed.)
Part 1: https://gist.github.com/2974698
Part 2: https://gist.github.com/2974700
This script gets nginx and Django up and working. It's in two parts because you have to log out and back in first to make the user permissions stick.
It sets up /var/www with a static folder, adds the user pi to a www-pub group for editing in /var/www, and starts a Django project in /var/www/django
It's using information from the following pages: https://code.djangoproject.com/wiki/DjangoAndNginx and http://serverfault.com/questions/6895/w ... ata-in-var
By the way, this is how to get the FastCGI running in the background as a daemon: https://code.djangoproject.com/wiki/InitdScriptForLinux (I haven't gotten this part to work yet)
Note: You're going to have to tweak your nginx settings depending on how you want your server set up, this just gets it up and started with the bare minimum setup. See http://wiki.nginx.org/DjangoFastCGI and http://stackoverflow.com/questions/6051 ... for-django
To make it easier on yourself, I'd put these into a text file like part1.sh and part2.sh, and run them as "sudo sh part1.sh" and "sudo sh part2.sh"
Let me know if you run into any issues. I tried this on a brand new Wheezy install, by the way.
(Fixed the FastCGI parameters that get passed.)
Part 1: https://gist.github.com/2974698
Part 2: https://gist.github.com/2974700
- Posts: 15
- Joined: Fri Mar 16, 2012 7:46 pm
Iam getting "502 Bad Gateway"
Whats the matter?
Thanks
Peter
Whats the matter?
Thanks
Peter
- Posts: 13
- Joined: Wed May 23, 2012 6:13 pm