HTTP Server for Embedded Systems with Busybox

Busybox has a built-in httpd server. Just turn it on, enable CGI and authorization etc, enable remote-port in env. Start the httpd. It works!

The tricky part comes with how to configure it. A quick fix is here:

Create the user account apach in /etc/passwd:
apach:x:48:48:webaccess:/www:/bin/false
and in /etc/group
apach:x:48:
and in /etc/shadow:
apach:x:48:
Change the ownership of /www and /etc/httpd.conf to apach:
chown apach:apach /etc/httpd.conf
chown -R apach:apach /www

By default, it will look for /etc/httpd.conf for setup information Here is a sample httpd.conf

  #httpd.conf
A:127.0.0.1
A:172.30. #Allow address from 172.30.0.0/16
D:* # Deny from any other IP connections
/cgi-bin:wli:123456 #require user wli, password on url starting with /cgi-bin

The following is a sample CGI script. Make sure the script has executable permission.

#!/bin/sh
echo "Content-type: text/plain"
echo "\r\n"
echo ""
echo "Sample CGI Output"
echo ""
echo ""
env
echo ""
echo ""

It’s that simple!

Or, take a look at more details on this openwrt page.

Advertisements

About minghuasweblog

a long time coder
This entry was posted in All, C/C++, LAMP and Drupal and tagged , , , , . Bookmark the permalink.

One Response to HTTP Server for Embedded Systems with Busybox

  1. Pingback: Web Application Backend by Busybox HTTP Server | minghuasweblog

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 )

Google+ photo

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

Connecting to %s