Linux Busybox Http Server

Linux Busybox Http Server

Occasionally I find myself needing a simple http server for testing or rendering static content. One of the simplest tools I found for this is the busybox httpd daemon. This post covers starting, stopping, and few other troubleshooting commands I use with this http server.

Assumptions

  • A Linux distribution such as Ubuntu with busybox
  • Familiarity with http and delivering content

Busybox Httpd Daemon

As mentioned above, one simple tool I frequently use from busybox is its httpd daemon. It is super simple and for a basic http server works fine.

Starting the Httpd Daemon

The busybox httpd daemon can be started with various configuration flags, or simply start it with defaults. The default will be the current directory and port 80. Creat some helloworld index.html file in the current working directory and then start the httpd daemon.
default Configuration
$ busybox httpd  
Home Directory and Port Configuration
$ busybox httpd -h /www/data -p 8080  

Verifying Httpd Daemon

Here are a couple methods to use to verify the http server is running.
netstat
$ netstat -tulnp  
fuser
$ fuser 80/tcp  

Stopping Httpd Daemon

A simple command to kill a TCP process is the ‘fuser’ command.
$ fuser -k 80/tcp