Share this post
FaceBook  Twitter  
Contents[Hide]

1. Introduction

Yes, I know: why another webserver tutorial when there are so many good Apache howtos on the Internet? Because this is about what we've been saying for a while: use the right tool for the right job. And while we don't want to badmouth Apache, which is indeed a quality webserver, it offers lots of capabilities that aren't needed on a small scale machine. That's like using a Hummer for commuting, when a Smart would do just fine, if not better. So, if you need to quickly be online and offer services with a small website, Monkey might be for you. We presume that you know what a webserver is and what it is exactly that you want to set up. Let's start then. Do not forget to visit our Linux forum if you need some help with this or any other Linux matter.

2. Getting and installing Monkey HTTPD

Although we couldn't find it in any distribution's repository nor in any of the BSDs, Monkey is simple to install from source and it also offers a spec file for Fedora plus a control file for Debian. So, go to Monkey HTTP Daemon's website and get the latest release or, if you feel adventurous, use git to stay in touch with the latest and greatest. As previously suggested, create a directory where you'll keep your third-party tarballs, download the source there, then do

 $ tar xzvf monkey-0.20.3.tar.gz
$ cd monkey-0.20.3

Please note that at this time, Monkey will run only on Linux as it depends on some Linux-specific system calls. We recommend you issue a

./configure --help

before you move further, because, besides controlling the usual options, like --prefix or --debug, you can set the default port Monkey will be listening to (if you don't alter it, the port will be 2001, as in Space Odyssey) or what plugins should be compiled. You can find the available plugins in the plugins/ directory, and we encourage you to look at the READMEs and ABOUT files to see what's what. So, we'll install in /usr/local with all the plugins enabled:

 $ ./configure --prefix=/usr/local --enable-plugins=auth,cheetah,dirlisting,liana,\
liana_ssl,logger,mandril,palm,patas

Take note that Monkey will not run on a kernel older than 2.6.29. The other requirements are pthreads and libc, which already exist on your system.

So, you'll have a Makefile if the configure script exited succesfully, so now you can compile Monkey. Please check the Makefile to see if it corresponds to your wishes, then issue

 $ make
 # make install

and that's about it. In /usr/local/bin you'll see the two installed executables: banana and monkey. Banana is a server control application in the vein of apachectl, and monkey is the main server application. For now, to test everything's fine, just run monkey with no arguments then point your browser to localhost:2001 (if you followed our example and left the default value for port). You should see something like this:

Monkey HTTPD Linux

We can only hope that everyone reading this knows what a reserved port is and the implications of listening on a port >1024. Think before you type ./configure, because it's an important option, however you can modify the port afterwards, as you will see.

3. Configuring Monkey

If you followed our path and installed monkey in /usr/local, then /usr/local/conf is the default place for config files, unless you altered the location through the configure script. So, get your root powers and your favorite text editor and open monkey.conf .

If you ever dealt with Python, you will feel at home here, because the general layout of the configuration file is based on indentation, which only gives it more clarity. It's divided in sections, marked by square brackets and commented by hashes. Before you alter anything here, take a look at the whole file to get an overall impression. The general options aren't much different from other webservers we have experience with, because, in the end, they all serve the same purpose. So the first section in monkey.conf is the [SERVER] section. which deals with the default port (remember that, as you're also told in the comments, only root can open a port below 1024), what to listen to (if you need only local connections, as in loopback, uncomment the "Listen 127.0.0.1" line). You should know what a worker is in webserver terms, and if you need to set this value much higher than it is, you may want to consider Apache.

The following options are easy for everyone with a bit of experience, so we will not detail them.These are Timeout, PidFile, UserDir (for pages of the form ~username), Indexfile, HideVersion, Resume (can be on or off) and User (nobody as default). What follows is the advanced subsection, and we recommend you change these values only if you know what you're doing. The last option sets the plugin that will provide the Transport Layer. By default in Monkey the plugin is called liana and liana_ssl for HTTPS. We'll show you how to enable plugins in a moment.

So, save the file, make sure that Monkey is not running, then you can start it (as root or as user, depending on your options) with 'banana start'. If everything went well, you now have a valid mini-webserver up and running.

Not so fast, though. We still have some files to edit before we can go into production. First there is monkey.mime, which controls the various MIME types used. Depending on the content you'll be serving, you might want to add some MIME types in here, although the file already has ~140 types listed.

Next is plugins.load, which, you guessed it, controls what plugins you want to load when Monkey starts. The file is in the same format as the main configuration file, discussed earlier, and the comments are pretty clear. Since we compiled all the plugins, which are nothing but .so files, we may enable them all, but only if we need to do so. Recommended are auth, dirlisting, logger, mandril and palm. The last two may not be as obvious by name as the others, so we'll describe them shortly. mandril is a plugin that allows the webmaster to restrict access based on IP and/or URI request. palm offers a simple interface for scripts written in PHP or Perl, for example. So after you save the file, remember to restart the server by doing a 'banana restart'.

We now go to the plugins directory, which offers a directory containing a configuration file for every plugin available. We'll take palm as an example, where you can configure what kind of scripts you'll be running. So, let's say that we want to add Python scripts. As you can see from the already existing lines (for PHP and Perl), it's as simple as

Extension py
Mimetype application/x-python
ServerAddr 127.0.0.1
ServerPort 2012

Now, let's go to the sites directory, which controls the vhosts part of a webserver. A minimal webserver driven by Monkey must have at least one vhost, which is already defined for you with the file named default. The [HOST] section defines by default ServerName as 127.0.0.1 and DocumentRoot as /usr/local/htdocs. Change the ServerName accordingly and, if you want your main content in a more usual location, change DocumentRoot to /var/www/htdocs or some other location if ,again, you know what you are doing. The [LOGGER] section is pretty easy to grasp, I think, so no need for explanations here, except that maybe you'll want to have your logs in /var/log/ (and you should configure the logger plugin accordingly). If you want to have more than the default vhost, create a file, using the default as a model, and alter it as you see fit.

4. Conclusion

Monkey HTTP Daemon offers you the possibility to have a fully-configured webserver in less than half an hour with little effort on your side. Nonetheless, remember that it's not designed for big payloads or complex, content-rich sites. If that is the case, we suggest another webserver, more suited to the task. Good luck.

Partners

Who are we?

LinuxCareer.com is not affiliated with any local or international company, nor is it a recruitment or employment agency. We specialise in Linux based careers and closely related Information Technology fields by providing careers advice and latest employment opportunities.

JOIN LINUXCAREER

You can also get involved in the LinuxCareer project by participating on our FORUM or SUBMITTING A LINUX ARTICLE. We offer a range of privileges to our authors and good company.