Common Gateway Interface (CGI) is an interface specification for web servers to execute programs like console applications. These applications run on a server to generates web pages dynamically. In this article I will try to connect a mumps script to Apache using a cgi script.

This article is part of the Mumps/M language series, make sure to go back to the main page for further reading.

Setting up apache

If you don’t have it installed yet, you will need to install the web server itself:

sudo apt-get install apache2

You can give it a try right away and check if the web server is working properly, by navigating to http://127.0.0.1/

The /etc/apache2/conf-available/serve-cgi-bin.conf file has a section that maps the /cgi-bin path to the /usr/lib/cgi-bin/ directory. it also enables CGI execution in this directory.

in addition to these settings, we will need to activate the CGI module on apache. This can be done by simply issuing the following commands:

sudo a2enmod cgi
sudo service apache2 restart

Mumps CGI script

I have written a simple Mumps CGI script that prints basic html tags. I should point out that it’s very important that you print the correct headers.

Mumps CGI
Mumps CGI

The output from this script is pretty straightforward. The following images display the page and it’s source code from the browser:

Hello world
Hello world
Hello world Source
Hello world Source

Leave a comment