Setup the thttpd server

On embedded system, use apache2 web server could be a luxury. I have used web2py web framework and it did run but crashed my flash drive. So I decided to keep it simple. thttpd has a very small footprint and said to be secure.  To install it in a debian system, just type

aptitude install thttpd

It will install as all the other packages. The next step is to configure the server, on my debian lenny, it is /etc/thttpd/thttpd.conf

I want to run python cgi programs, so the cgipattern /cgi-bin/*  seems fit my needs.

The default cgi script directory is /var/www/cgi-bin and default html docs are under /var/www

You need make sure the cgi scripts have 755 permission and chown to www-data.

cgi program need print two empty lines , so the simplest cgi will be

#!/usr/bin/python

print “Content-type: text/plain\n\n”

And this works in apache, however it doesn’t work on thttpd.  After struggled several hours in reading the manual, options and digging through the mail list archives, check the thttpd server log and syslog for errors. I still have no clue.

Somehow, before I give up, I find a chroot option in configuration file. I change it to nochroot, because if I do the chroot, python couldn’t run for I haven’t duplicated the /usr/python into /cgi-bin directory.  That’s it! Now it runs.  I have to admit : thttpd is too secure…

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.