Using the Mongoose light web server

Introduction

Mongoose is a basic web server available for Windows and *nix that only requires a single binary. It also supports PHP and other scripting engines.

Setup

To run Mongoose in its most basic form, simply download and run the binary.

Configuration

Mongoose is configured through mongoose.conf that must be located in the same directory as mongoose.exe. On *nix, it can also be located in /etc to avoid putting a configuration file in of /usr/bin.

Port

By default, Mongoose listens on TCP 8080, but you can use "listening_ports 12345" to force it to open a different port.

CGI extensions

To tell Mongoose which files to consider as CGI scripts, use eg. "cgi_extensions          .php,,"

Directory Listing

Disabled by default. Enable with "enable_directory_listing yes"

Directory index files

By default, "index.html,index.htm,index.cgi". Can be changed through "index_files"

Adding support for PHP

By default, Mongoose considers any file with extension .php as a PHP file and run it through the interpreter mentionned in its shebang line or through the "cgi_interpreter" in mongoose.conf.

Adding support for Python

  1. Download and install Python
  2. Edit mongoose.conf:

    cgi_pattern **.cgi$|**.pl$|**.php$|**.py
     
  3. Restart Mongoose
  4. Write a Python script with extension ".py" and the shebang line pointing to the Python interpreter (python.exe). Here's an example:

    #!C:\Python25\python.exe

    print "Content-Type: text/plain"
    print
    print "Hello, World!"

  5. Run Mongoose and aim your browser to the script

Resources