Hello, I would like to know how to setup D language project, so that it would work with Apache httpd cgi.

Do I need some kind of cgi library for D language? Right now all I'm getting is internal server error.

Btw. Unix Bash script examples seems to work well with with Apache httpd cgi, they do not show internal server error.


Before trying examples below, it is required that you install apache httpd:
sudo apt-get install apache2

And enable cgi module
sudo a2enmod cgi
sudo service apache2 restart

Here are examples:

D language example, this one does not work. Give internal error.

/usr/lib/cgi-bin/example.d
#!/usr/bin/env rdmd
import std.stdio;
void main()
{
   writeln("Hello, world with automated script running!");
}


Bash example, this one working perfectly.

/usr/lib/cgi-bin/example.sh
#!/bin/bash
echo "Content-type: text/html"
echo ''
echo 'CGI Bash Example'


Also remember to chmod the examples, before opening them:
sudo chmod 755 /usr/lib/cgi-bin/example.sh
sudo chmod 755 /usr/lib/cgi-bin/example.d

Reply via email to