Hi,
Wenn ich bei gestartetem Webserver versuche ein Perl-Script im Browser zu starten erhalte ich den "Speichern unter..." Dialog anstatt einer Ausgabe im Browser. Wenn ich ein Perl-Script per Doppelklick starte oder im "Speichern unter..." Dialog "Öffnen" auswähle, startet das Script wie erwartet in einer Dos-Box.
Wer kann mir erklären, woran das liegen mag? Vielen Dank schon mal im voraus... Alex
Ordnerstruktur (Windows):
c:/Apache
c:/Apache/Apache --> "Apache 1.3.24"
c:/Apache/Htdocs --> "Webseiten"
c:/Apache/Htdocs/Cgi-bin --> "Scriptordner"
c:/Apache/Perl --> "ActiveState Perl 5.6.1"
Test Script mit Shebang Variationen:
#!/usr/bin/perl
#!c:/apache/perl/bin/perl.exe
#!c:/apache/perl/bin/perl
#!c:/apache/perl/bin
## printenv -- demo CGI program which just prints its environment
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\n|g;
$val =~ s|"|\"|g;
print "${var}="${val}"\n";
}
Httpd.conf (Ausschnitt):
...
ServerName localhost
DocumentRoot: The directory out of which you will serve your
documents. By default, all requests are taken from this directory, but
symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:/Apache/Htdocs"
Each directory to which Apache has access, can be configured with respect
to which services and features are allowed and/or disabled in that
directory (and its subdirectories).
First, we configure the "default" to be a very restrictive set of
permissions.
<Directory "C:/Apache/Htdocs">
Options All
AllowOverride None
</Directory>
Note that from this point forward you must specifically allow
particular features to be enabled - so if something's not working as
you might expect, make sure that you have specifically enabled it
below.
This should be changed to whatever you set DocumentRoot to.
<Directory "C:/Apache/Htdocs">
This may also be "None", "All", or any combination of "Indexes",
"Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
Note that "MultiViews" must be named *explicitly* --- "Options All"
doesn't give it to you.
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
This controls which options the .htaccess files in directories can
override. Can also be "All", or any combination of "Options", "FileInfo",
"AuthConfig", and "Limit"
AllowOverride None
Controls who can get stuff from this server.
Order allow,deny
Allow from all
</Directory>
...
Apache parses all CGI scripts for the shebang line by default.
This comment line, the first line of the script, consists of the symbols
pound (#) and exclamation (!) followed by the path of the program that
can execute this specific script. For a perl script, with perl.exe in
the C:\Program Files\Perl directory, the shebang line should be:
#!c:/apache/perl/bin/perl
Note you _must_not_ indent the actual shebang line, and it must be the
first line of the file. Of course, CGI processing must be enabled by
the appropriate ScriptAlias or Options ExecCGI directives for the files
or directory in question.
However, Apache on Windows allows either the Unix behavior above, or can
use the Registry to match files by extention. The command to execute
a file of this type is retrieved from the registry by the same method as
the Windows Explorer would use to handle double-clicking on a file.
These script actions can be configured from the Windows Explorer View menu,
'Folder Options', and reviewing the 'File Types' tab. Clicking the Edit
button allows you to modify the Actions, of which Apache 1.3 attempts to
perform the 'Open' Action, and failing that it will try the shebang line.
This behavior is subject to change in Apache release 2.0.
Each mechanism has it's own specific security weaknesses, from the means
to run a program you didn't intend the website owner to invoke, and the
best method is a matter of great debate.
To enable the this Windows specific behavior (and therefore -disable- the
equivilant Unix behavior), uncomment the following directive:
ScriptInterpreterSource registry
The directive above can be placed in individual <Directory> blocks or the
.htaccess file, with either the 'registry' (Windows behavior) or 'script'
(Unix behavior) option, and will override this server default option.
...
Alias /root/ "C:/Apache/Htdocs/"
<Directory "C:/Apache/Htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "C:/Apache/Htdocs/cgi-bin/"
ScriptAlias /pl/ "C:/Apache/Htdocs/cgi-bin/"
#
# "C:/Apache/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "C:/Apache/Htdocs/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
</IfModule>
End of aliases.
...
# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
AddHandler cgi-script .cgi .pl
Action application/x-httpd-cgi /perl/perl.exe
...