tags:

views:

517

answers:

4

On Windows, the following registry setting configures the script interpreter to be used by Apache:

HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command=C:\Perl\bin\perl.exe

How is this done on Linux?

A: 

There is no registry under Linux. Also, I doubt you will get Perl.exe running under Linux.

Bombe
Actually there is gconf which is sort of a registry for GNOME, but generally speaking, you're right.
DrJokepu
This answer is not helpful.
Brad Gilbert
That wasn't what the OP asked, and is not helpful.
MarkR
+1  A: 

ScriptInterpreterSource is an Apache configuration setting and is only supported on Windows. I'm not really experienced at configuring Apache on Linux but I reckon you should check out the Script directive.

DrJokepu
+5  A: 

If you are talking about CGI script handlers.

It is set on the first line of each CGI script, I frequently use TCL as my script handler in Apache and hence add:

#!/bin/tclsh

Add this line on top of your script, eg. test.cgi and it will be executed by TCL shell whenever it is requested by someone.

Similary you can set it as

for BASH -- #!/bin/sh

or

for PERL -- #!/usr/bin/perl

Note: The path for the shell binary executable can be different, from above, on your machine. Use the following command to find it:

#which perl


Also, as Max has suggested, do check if Apache is configured to allow CGI scripts Find detailed description of the same here at this Apache Tutorial Link

Mohit Nanda
Don't forget to double check that apache.conf allows CGIs ( http://httpd.apache.org/docs/1.3/howto/cgi.html#scriptalias ).
Max Lybbert
Thanks Max! Have incorporated your suggestion in the answer.
Mohit Nanda
+4  A: 

To add a bit more information to @Mohit's good answer:

Unix uses many interpreters for many languages. Some of them are called "shells", but most are just another computer language to the system. In fact, every file is written in some language, even if it's compiled assembly of Java bytecodes.

The first few bytes of a file are "magic": they tell the OS how to execute the file. If the first two bytes are '#!', the OS knows that the file needs an interpreter. The rest of the first line up to newline is then used as a command to execute. The first "word" (space-separated group of non-spaces) of the line is interpreted as absolute file name to run, and all the other words are passed to it as command line arguments. Last parameter is the file name of the file you're running.

So, for example, if you have the first line as

#!/bin/tclsh

in a file /home/user/aaa.tcl

the OS will execute /bin/tclsh with /home/user/aaa.tcl as command line argument:

/bin/tclsh /home/user/aaa.tcl

For a more advanced example, try this:

#! /bin/env perl

in /home/user/myperlscript

This executes the following command:

/bin/env perl /home/user/myperlscript

/bin/env is a utility program that looks up its first argument using PATH environment variable, and then executes the program it finds, passing the rest of its arguments on to the program. With the help of env, you can use PATH to find your interpreters.

Arkadiy
Don't forget to double check that apache.conf allows CGIs ( http://httpd.apache.org/docs/1.3/howto/cgi.html#scriptalias ).
Max Lybbert