I’ve been working hard on a project lately called Debrew that adds a web interface to a CNC controller. I decided to go for Lighttpd as the web server, Web.py as the Python framework, and sqlite3 as the data base engine. Here is how I did it.
I’m going to write up the whole project in a different post, but I just wanted to post the instructions for getting a basic web interface going on BeagleBone Black. This post assumes using Angstrom (or similar OpenEmbedded flavour, I guess) as the distro. In the following instructions, I’m assuming starting from the Thing image. This image is very minimal, so it lacks stuff like Git.. The most important difference from a Debian based distro is perhaps the package handling system. The instructions are specific for Debrew, so just exchange your project for this.
opkg install git opkg install python-compile opkg install wget opkg install python-setuptools
Instructions for installing the software:
opkg install lighttpd opkg install sqlite3 opkg install lighttpd-module-fastcgi opkg install lighttpd-module-rewrite opkg install lighttpd-module-alias opkg install python-sqlite3
cd /usr/src/ git clone git://github.com/webpy/webpy.git cd webpy python setup.py install
transfer python software
make debrew.py executable:
chmod +x /www/pages/debrew/debrew.py
Edit the lighttpd config file to enable serving Python files:
nano /etc/lighttpd.conf enable mod_alias, mod_fastcgi, mod_rewrite by commenting out the # opn that line.
Add this to the end of the file:
fastcgi.server = ( ".py" => (( "socket" => "/tmp/fastcgi.socket", "bin-path" => "/www/pages/debrew/debrew.py", "max-procs" => 1, "bin-environment" => ( "REAL_SCRIPT_NAME" => "" ), "check-local" => "disable" )) ) url.rewrite-once = ( "^/favicon.ico$" => "/static/favicon.ico", "^/static/(.*)$" => "/static/$1", "^/(.*)$" => "/debrew/debrew.py/$1", )
The lighttpd systemd file is broken, so make sure it looks like this:
Should look like this:
[Unit] Description=Lightning Fast Webserver With Light System Requirements After=syslog.target [Service] EnvironmentFile=-/etc/sysconfig/lighttpd ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd.conf [Install] WantedBy=multi-user.target
cd /usr/src wget --no-check-certificate https://pypi.python.org/packages/source/f/flup/flup-1.0.tar.gz#md5=530801fe835fd9a680457e443eb95578 tar -vxf flup-1.0.tar.gz cd flup-1.0/ python setup.py install
systemctl restart lighttpd
If there are problems during the development, make sure you check both /www/logs/lighttpd.error.log and syslog (journalctl).
Update: With the new Thing-image, this is already pre-installed.