Servers

DIY: You'll go bananas for the Monkey web server

The Monkey HTTP daemon is an easy way to get a web server up and running on smaller or embedded systems.

If you're looking for a fast, lightweight web server that is scalable and requires very low memory, you should check out Monkey. (Honestly, how can you not want a monkey on your Linux server?) Monkey is not as powerful and feature-rich as Apache; it's better suited for small servers (even embedded systems) that only need to serve static content quickly and with little overhead (think self-contained kiosks and other such devices).

Monkey's features include:

  • HTTP/1.1
  • Virtual Hosts
  • Asynchronous networking model (event-driven)
  • Indented configuration
  • Plugins Support
  • C API Interface

Other features available through plugins include:

  • SSL
  • Security
  • Log writer
  • Directory Listing
  • Shell: Command line

Monkey works so efficiently by using a hybrid of posix threads and Epoll() system calls, with each thread capable of 200 concurrent requests. By itself, Monkey focuses strictly on static content. With the help of the Palm application server, Monkey can serve up dynamic content as well. The Palm application server is included with the Monkey installation.

Installing Monkey

The Monkey HTTP daemon is so easy to install that you can have the server up and running in a couple of minutes. Monkey can be installed from the Add/Remove Software tool (found in the default repositories of Ubuntu), or it can be installed from source. The installation from the Add/Remove software tool is self-explanatory, so I'll walk you through the installation from source.

  1. Download the latest source file for Monkey.
  2. Open a terminal window.
  3. Unpack the source file.
  4. Change into the newly created directory.
  5. Run the configure command with all of the options necessary*.
  6. Run the sudo make command with no options.
  7. Run the sudo make install command with no options.

* For the configure command, you will need to instruct Monkey where various directories are housed. Here is the command I ran for the configuration of Monkey on a Ubuntu server system:

./configure --bindir=/usr/bin/ --datadir=/var/www/monkey --logdir=/var/log/monkey -plugdir=/var/www/monkey/plugins -sysconfdir=/etc/monkey

where:

  • /usr/bin is the directory housing the executables.
  • /var/www/monkey is the directory housing data (docs, images, php code).
  • /var/log/monkey is the directory that holds the Monkey log files.
  • /var/www/monkey/plugins is the directory housing the plugins.
  • /etc/monkey/ is the configuration directory.

Once you have settled your configure command, issue it and then follow it up with the sudo make and sudo make install commands. Monkey is now installed and ready to be started and configured.

Starting Monkey

Based on the configuration command issued above, I would issue the command sudo monkey -D to start Monkey in daemon mode. You can test Monkey by pointing your browser to http://ADDRES_TO_MONKEY_SERVER:2001 to see the Monkey splash page (Figure A). Figure A

How can those smiling faces not bring you at least a moment of happiness?

Configuring Monkey

In the directory you defined as your sysconfdir, you'll see the monkey.conf file; this file is where all Monkey configurations are handled. In this file, you can configure things such as:

  • Port: Port Monkey listens on.
  • Listen: Restrict Monkey from listening to addresses.
  • Workers: How many worker threads to be launched.
  • Timeout: Span of time to wait to receive information.
  • Pidfile: Process ID file for use by Monkey.
  • UserDir: Directory name for users home.
  • Indexfile: Type of index files that are useable (such as index.html, index.htm, index.php).
  • User: The username the server should run under.

There are even more configuration options, so look through the file to see what needs to be configured for your needs.

Adding sites/pages

Based on the configuration command I ran, pages and sites are added within the /var/www/monkey directory. If I were to create a simple index.html page, place it into that directory, and point the browser to http://ADDRESS_TO_SERVER/monkey/, the index page would be displayed. But what if you want to make use of virtual hosts? That's right -- this small and simple http server can also serve up virtual sites. In order to make use of virtual sites, you have to create a new definition file in the /etc/monkey/sites directory (which might change, depending upon where you define your sysconfdir in the configure command). Each definition file will require the following directives:

DocumentRoot: The root directory of the web server

Servername: The address (or name) of the server

At a bare minimum, that is all you need. You can compare any new virtual hosts file you create with the default file (aptly named "default"). What is really amazing about this little server is that you don't have to restart Monkey after creating a new virtual site.

Conclusion

Don't let Monkey's size fool you -- it's agile, powerful, and scalable. Give this web server a try, and see if it can't take the place of your current web server.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

1 comments
Neon Samurai
Neon Samurai

If your working on a .DEB based system, make sure you have the "checkinstall" package installed. Then with the steps listed in the article: ... 4. change to newly created directory 5. ./configure 6. sudo checkinstall It will do the "sudo make" but then create a .DEB package out of the resulting program. You can then install and uninstall it through the normal package manager instead of letting the naked "sudo make install" copy files into your system without a clear method of uninstall/upgrade later.

Editor's Picks