【问题标题】:What causes Apache to invoke an executable on the server?是什么导致 Apache 调用服务器上的可执行文件?
【发布时间】:2015-07-16 16:22:14
【问题描述】:

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

index.html 有:

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

“启动”如何开始?

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

【问题讨论】:

    标签: html apache http


    【解决方案1】:

    有几件事需要设置。

    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

    -- 来自新信息--

    <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,看看是否有区别..

    【讨论】:

    • 您好,谢谢您的反馈,ScriptAlias /admin/ "/opt/tms/lib/web/cgi-bin/" Options +ExecCGI AllowOverride None Options None Order Allow, Deny Allow from all
    • 是由 Apache 运行的用户启动的可执行文件。你有没有加载cgi模块
    猜你喜欢
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 2011-11-13
    • 2010-10-29
    相关资源
    最近更新 更多