Table of Contents

CGI Hello World Example

Here are a few example Hello World CGI applications written in different languages.

Please make sure your webserver config has cgi properly set up first. For example, boa needs to have AddType application/x-httpd-cgi cgi enabled in boa.conf.

Finally, make sure the files are marked with executable permissions on the server.

Shell Code Example


echo "Content-type: text/html"
echo ""

echo "<html>"
echo "<head><title>CGI example</title></head>"
string="Hello world!"
cat << EOF
echo "</html>"

C Code Example

#include <stdio.h>

int main(int argc, char *argv[])
    printf("Content-type: text/html\r\n");

        "<head><title>CGI example</title></head>"
        "<body>Hello world!</body>"