Topic: Lighttpd and cgi-bin on USB Drive

Hello,
    I finally got mu USB Drive for the Chumby and installed Lighttpd. I then tried to move the wireless Stats and Radio files from the /psp/cgi-bin files into the /lighty/cgi-bin file (Moved correctly) howerver wehn I try to browse to http://MyChumbyIPAddress/cgi-bin/radio, I get a HTTP 404 Page Not Found Message.

I even chmod +x <name of file> and no improvement, Any ideas?

Re: Lighttpd and cgi-bin on USB Drive

Are you shutting down the builtin httpd when you start lighttpd?  The script supplied with the binaries should have done that - but I recommend checking using 'ps'.

You can also turn on lighttpd's logging (say, to somewhere in /tmp)  and see what *it* thinks is going on.

Re: Lighttpd and cgi-bin on USB Drive

Yes I used the debugchumby script to shutdown the built in httpd server

BusyBox v1.6.1 (2007-11-06 18:16:48 PST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

chumby:~# ps
  PID  Uid        VSZ Stat Command
    1 root       1648 SW  init
    2 root            SWN [ksoftirqd/0]
    3 root            SW  [watchdog/0]
    4 root            SW< [events/0]
    5 root            SW< [khelper]
    6 root            SW< [kthread]
   14 root            SW< [kblockd/0]
   17 root            SW< [khubd]
   59 root            SW  [pdflush]
   60 root            SW  [pdflush]
   62 root            SW< [aio/0]
   61 root            SW  [kswapd0]
  679 root            SW  [mtdblockd]
  680 root            SW  [ftld]
  681 root            SW  [nftld]
  718 root            SW< [scsi_eh_0]
  719 root            SW< [usb-storage]
  982 root            SWN [jffs2_gcd_mtd1]
  990 root       1848 SW  /sbin/syslogd -C200
  992 root       1588 SW< /sbin/udevd --daemon
 1031 root       3164 SW  mountmon --daemon
 1278 root       1504 SW  headphone_mgr /proc/sys/sense1/hpin /proc/sys/sense1/
 1542 root            DW  [rt73]
 1543 root            DW  [rt73]
 1780 root      20808 SW  chumbhowld
 1796 root       4136 SW  /usr/sbin/crond -c /etc/cron/crontabs
 1808 root       1904 SW  /mnt/usb/lighty/sbin/lighttpd -f /mnt/usb/lighty/ligh
 1811 root       1648 SW  init
 2012 root       1652 SW  udhcpc -t 5 -n -p /var/run/udhcpc.rausb0.pid -i rausb
 2116 root       2876 SW  /sbin/sshd
 2119 root       5508 SW  sshd: root@pts/0
 2123 root       4140 SW  -sh
 2133 root       1652 SW  /bin/sh /usr/chumby/scripts/start_control_panel
 2178 root       3164 SW  /usr/bin/perl /usr/chumby/scripts/download_cp
 2204 root       1648 SW  sh -c wget --progressbar --progress=bar:force -O /tmp
 2205 root       2388 SW  wget --progressbar --progress=bar:force -O /tmp/contr
 2206 root       4140 RW  ps
chumby:~#

I will turn on logging to see what is going on

Re: Lighttpd and cgi-bin on USB Drive

I still cannot seem to get this to work, the HTML Pages are properly displaying but the GGI Scripts are failing, Any other advice?

And hopfully bopp has had some luck with his PHP Port, I have done ALOT of work with PHP so I may hold off until that comes out(Hopefully Soon)

Re: Lighttpd and cgi-bin on USB Drive

i went through some headaches getting 404's for scripts i was putting on my chumby. my issue was incorrect line terminations. this also produced a 404 (even though the file was in the right place).

Re: Lighttpd and cgi-bin on USB Drive

I tried everything on the Post, It is still failing, However the scripts work when placed on the /psp/cgi-bin rather then /mnt/usb/lighty/cgi-bin , These do not work. I tried using proper unix style line terminations, Including vi.

Re: Lighttpd and cgi-bin on USB Drive

Has there been any progress on this issue? I just installed Lighttpd on my USB stick and am having the same problem. HTML files are served just fine, but scripts in lighty/cgi-bin give me a 404 error.

@KMyers, how did you get your scripts in /psp/cgi-bin to run? I've tried editing the lighttpd.conf to point cgi.assign there: cgi.assign = ( "/psp/cgi-bin"),  but it doesn't help and nothing else seems to work.

Duane, any new thoughts?

Thanks all.

Re: Lighttpd and cgi-bin on USB Drive

No ideas here - the stuff for lighttpd is an unsupported hack.

All I can suggest it to turn on logging and see what's happening, and maybe rebuild the binaries from source if necessary.

Re: Lighttpd and cgi-bin on USB Drive

Duane wrote:

No ideas here - the stuff for lighttpd is an unsupported hack.

All I can suggest it to turn on logging and see what's happening, and maybe rebuild the binaries from source if necessary.

OK, fair enough. I'll poke around and see what I can find. Pardon my ignorance, I've been going thru the lighttpd docs and haven't found the answer --  do I turn logging on via a switch in the lighttpd.conf file or is there another place this is set. Thanks.

Re: Lighttpd and cgi-bin on USB Drive

I think the relevant lines in the lighttpd.conf file are:

server.errorlog = "/tmp/logs/lighttpd.error.log"
accesslog.filename = "/tmp/logs/lighttpd.access.log"

It may be that you're already logging if you're using the default binaries I posted.  I don't think you have to load another module to get error logs like you do with access logs.

11

Re: Lighttpd and cgi-bin on USB Drive

Duane wrote:

I think the relevant lines in the lighttpd.conf file are:

server.errorlog = "/tmp/logs/lighttpd.error.log"
accesslog.filename = "/tmp/logs/lighttpd.access.log"

It may be that you're already logging if you're using the default binaries I posted.  I don't think you have to load another module to get error logs like you do with access logs.

yep, I'm using the default binaries and have those two lines modified to point to a directory on my flash drive:

server.errorlog = "/mnt/usb/lighty/logs/lighttpd.error.log"
accesslog.filename = "/mnt/usb/lighty/logs/lighttpd.access.log"

In the access log I see:

192.168.1.201 192.168.1.202 - [27/Jan/2008:00:44:06 -0800] "GET /cgi-bin/wifi HTTP/1.1" 404 345 "-" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/523.12.2 (KHTML, like Gecko) Version/3.0.4 Safari/523.12.2"

In the error log I only have one entry:

2008-01-25 23:15:44: (log.c.75) server started

I got the same results when I used the original lighttpd.conf file with the log files going to /tmp/logs

It looks like CGI errors aren't logging. Wonder if this might be related to scripts not working???

Re: Lighttpd and cgi-bin on USB Drive

OK, I'll see if I can carve out some time to look at this. It pretty much has to be a configuration issue, or an issue with running CGI scripts from a VFAT partition.

Re: Lighttpd and cgi-bin on USB Drive

OK, here's what to do.  Change the top part of the lighttpd.conf file to:

server.modules = ( "mod_cgi", "mod_accesslog", "mod_alias" )
server.document-root = "/mnt/usb/lighty/html"
server.errorlog = "/tmp/logs/lighttpd.error.log"
accesslog.filename = "/tmp/logs/lighttpd.access.log"
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
cgi.assign = ( ".sh" => "/bin/sh" )
alias.url = ( "/cgi-bin/" => "/mnt/usb/lighty/cgi-bin/" )

Note the addition of the mod_alias module in the server.modules line, the change to the cgi.assign line, and the addition of the alias.url line.

You can add additional cgi bindings in the cgi.assign line, ie ".pl" => "/usr/bin/perl" or whatever.

A simple example: in file /mnt/usb/lighty/cgi-bin/chumbyps.sh, put:

#!/bin/sh
echo Content-type: text/html
echo
echo "<html><head><title>ps</title></head>"
echo "<body><pre>"
ps
echo "</pre></body>"
echo "</html>"

This can be accessed with http://the.ip.of.chumby/cgi-bin/chumbyps.sh

14 (edited by dhl 2008-01-27 17:15:49)

Re: Lighttpd and cgi-bin on USB Drive

awesome! Thank you Duane, it's now working like a champ!

One tweak  I made to the lighttpd.conf file that others might find useful --

In order to tell the server where other directories are, i.e. an images directory at /mnt/usb/lighty/images, add an additional alias.url line like so:

alias.url += ( "/images/" => "/mnt/usb/lighty/images/" )

now time to see what this puppy can do...

Re: Lighttpd and cgi-bin on USB Drive

<BOWS>Duane<BOWS>