是什么导致Apache调用服务器上的可执行文件



我在服务器上有一个可执行文件,该文件应该由浏览器调用,但浏览器将其作为二进制文件下载到" downloads "目录。

index.html有:

 <head>
     <title></title>
     <meta HTTP-EQUIV="Refresh" CONTENT="0; URL=admin/launch?script=rhtemplate=login">
 </head>

"launch"是如何开始的?

ScriptAlias /admin/ "/opt/tms/lib/web/cgi-bin/"
<Directory "/opt/tms/lib/web/cgi-bin">
     Options +ExecCGI
     AllowOverride None
    Options None
     Order Allow,Deny
    Allow from all
</Directory>

在httpd 2.0中使用;我们更新到2.2

有一些东西需要设置。

http://httpd.apache.org/docs/2.4/howto/cgi.html

您可以将您的可执行文件放在ScriptAliased目录中。默认的apache配置通常有/cgi-bin/作为ScriptAlias。所以,如果你把你的脚本移动到那里,它应该只是工作。

ScriptAlias "/scripts/" "/usr/local/apache2/scripts/"

可以用来设置不同的目录,或者如果默认不包含它,可以创建一个目录。

或者,如果您想允许在ScriptAlias目录之外执行,您可以在目录中设置Options +ExecCGI,然后告诉Apache应该将哪些作为脚本处理。

启用该目录下的cgi执行

<Directory "/usr/local/apache2/htdocs/admin">
    Options +ExecCGI
</Directory>

然后你需要告诉Apache哪些扩展应该被视为cgi使用处理程序

AddHandler cgi-script .cgi .pl

所以你需要将你的脚本重命名为launch.cgi

——from new info——

<Directory "/opt/tms/lib/web/cgi-bin">
     Options +ExecCGI
     AllowOverride None
    Options None
     Order Allow,Deny
    Allow from all
</Directory>

你有Options noneOptions +ExecCGI在那一节,删除Options none,看看这是否有区别。

最新更新