Raspberry Pi Endeavours 10 – lighttpd web server

The web page the controls the Pi Car lives on a little webserver running on the Pi, we use lighttpd.

sudo apt-get install lighttpd

This creates a www directory in /var/www with a default index file, which i renamed to make way for our web files. I also added in the cgi-bin full of scripts to control the GPIO pins, and used the linux command ‘chown’ to change the ownership of the directory cgi-bin to www-data.

Lighttpd Config

By default, apparently cgi-bin files should be located under ‘/usr/lib/cgi-bin’, so I told lighttpd’s config file (under /etc/lighttpd/lighttpd.conf) that my cgi-bin files were located in /var/www.

lighttpd.conf

server.modules = (
“mod_access”,
“mod_alias”,
“mod_compress”,
“mod_redirect”,
“mod_rewrite”,
“mod_cgi”
)

server.document-root = “/var/www”
server.upload-dirs = ( “/var/cache/lighttpd/uploads” )
server.errorlog = “/var/log/lighttpd/error.log”
server.pid-file = “/var/run/lighttpd.pid”
server.username = “www-data”
server.groupname = “www-data”
server.port = 8083
index-file.names = ( “index.php”, “index.html”, “index.lighttpd.html” )
url.access-deny = ( “~”, “.inc” )
static-file.exclude-extensions = ( “.php”, “.pl”, “.fcgi” )

compress.cache-dir = “/var/cache/lighttpd/compress/”
compress.filetype = ( “application/javascript”, “text/css”, “text/html”, “text/plain” )

# default listening port for IPv6 falls back to the IPv4 port
include_shell “/usr/share/lighttpd/use-ipv6.pl ” + server.port
include_shell “/usr/share/lighttpd/create-mime.assign.pl”
include_shell “/usr/share/lighttpd/include-conf-enabled.pl”

$HTTP["url"] =~ “/cgi-bin/” {
cgi.assign = ( “” => “” )
}

cgi.assign = (
“.cgi” => “”
)

 

I also ran the command ‘lighty-enable-mod cgi’ that the lighttpd home page instructed me to do, restarted the Pi, and then went to the Pi’s IP address, on the port that I had specified in lighttpd (8083 in this case). The Pi now drives! After changing two wires, the Pi now drives correctly, all thats left is to add the traction-reduction tape to the wheels, and it will be rolling.