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:
- Virtual Hosts
- Asynchronous networking model (event-driven)
- Indented configuration
- Plugins Support
- C API Interface
Other features available through plugins include:
- 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.
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.
- Download the latest source file for Monkey.
- Open a terminal window.
- Unpack the source file.
- Change into the newly created directory.
- Run the configure command with all of the options necessary*.
- Run the sudo make command with no options.
- 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
- /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 MonkeyBased 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?
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.
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.
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.
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 jackwallen.com.