I'm on a hosted linux web server running Apache 2.2.25. The following shtml just shows the contents of the perl script rather than executing the script. I understand that the script runs from ssh (I don't have access to ssh). I'm sure I'm missing something in the .htaccess file. Any help would be gratefully received.
shtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Perl</title>
</head>
<body>
<!--#exec cgi="cgi-bin/test.pl"-->
</body>
</html>
perl (test.pl)
#!/usr/bin/perl
print "HELLO FROM PERL";
.htaccess
AddHandler cgi-bin .pl .cgi
AddType text/html .shtml .php
AddOutputFilter INCLUDES .shtml .php
Options +Includes
ExecCGII'm guessing your
cgi-bindirectory is notScriptAlias'ed, in which case you will need to use theExecCGIoption in addition to setting a handler:Also make sure that Apache has execute permissions for your scripts. See Configuring Apache to permit CGI for details.
#include virtualAlso, you should use the SSI command
#include virtualinstead of#exec cgi:According to the Apache manual:
What's worse,
#execcan be used to run arbitrary code on your web server. It's actually best to disable it completely:#includealso allows you to pass arguments to your CGI via the query string, e.g.which you can't do with
#exec.Note that the argument you pass to
#include virtualis a URL relative to the current document, not a file path.I would recommend reading Apache's Introduction to Server Side Includes if you haven't already.
XBitHackFinally, instead of requiring SSI files to have a special file extension (
.shtml), I prefer to use theXBitHackdirective:Any
text/htmlfile with the user execute bit set will be parsed for SSI. This means you don't have to rename files (possibly breaking links or users' bookmarks) when you want to add SSI to them.Putting it all together, I would set
.htaccesslike this: