Mobile app version of vmapp.org
Login or Join
Gonzalez347

: Adding custom handlers I have a number of D language programs (.d extension) and a compile-and-run tool (rdmd)--I'd like to configure Apache (version 2.2) to handle URLs such as "mysite.com/d/hello.d"

@Gonzalez347

Posted in: #Apache #Apache2

I have a number of D language programs (.d extension) and a compile-and-run tool (rdmd)--I'd like to configure Apache (version 2.2) to handle URLs such as "mysite.com/d/hello.d" by running rdmd with the requested resource. The programs do output valid HTTP headers.

I've researched AddHandler and Action, but have been unsuccessful in getting them to do what I want, namely executing rdmd with the resource. I suspect that the problem is that rdmd needs to be in some special cgi directory.

Can someone walk through the steps necessary to configure Apache on a Debian based system, such that it executes my files instead of offering them up for download? Directory specific ('/d') or site-wide execution are both fine.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

The D files should be treated as CGI programs. Add a CGI handler for the .d extension and enable the ExecCGI option. For example:

<Directory /var/www/public_html>
Options +ExecCGI
AddHandler cgi-script .d
</Directory>


Of course you need to change the directory path to match your setup.

Also, be sure to check the permissions settings of the .d files. The server doesn't run the files as your user account, so they need to be executable by everyone. Running this on the command line in the folder with your D programs should do it:

chmod a+x *.d


Because the files are now executable, they will be run using the program listed in the shebang line of each script. This is where rdmd comes in. The first line in each file should be something similar to this:

#!/usr/bin/rdmd


I don't know the specifics for the D language. Be sure and use the path to your rdmd compiler. If your not sure run this on the command line:

which rdmd


That should tell you where it is.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme