配置lighttpd以处理CGI C可执行文件

发布于 2024-11-14 04:02:36 字数 479 浏览 6 评论 0原文

有谁知道如何配置lighttpd来处理普通的CGI可执行文件(在本例中是用C编写的)?我编译了一个测试程序(test.cgi)并将其放在$HOME/public_html/cgi-bin中。我还使用 lighty-enable-mod cgi 启用了 CGI 模块并重新启动了 Web 服务器。尽管如此,在请求 http://localhost/~august/cgi-bin/test.cgi 程序不会运行,而是被视为静态文件。顺便说一下,这是我的测试程序:

#include <stdio.h>

int main(void)
{
   printf("Content-type: text/plain\n\n");
   puts("test...");
   return 0;
}

Does anyone know how to configure lighttpd to handle plain CGI executables, in this case written in C? I have compiled a test program (test.cgi) and put it in $HOME/public_html/cgi-bin. I have also enabled the CGI module with lighty-enable-mod cgi and restarted the web server. Still, when requesting http://localhost/~august/cgi-bin/test.cgi the program is not run but is instead treated as a static file. Here is my test program by the way:

#include <stdio.h>

int main(void)
{
   printf("Content-type: text/plain\n\n");
   puts("test...");
   return 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大姐,你呐 2024-11-21 04:02:36

默认的CGI配置如下所示:

$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = ( "" => "" )
}

即仅执行文档根目录下的cgi-bin目录中的二进制文件。要启用每用户 cgi 目录,请添加

$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" {
    cgi.assign = ("" => "")
}

到lighttpd 配置文件中。

The default CGI configuration looks like this:

$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = ( "" => "" )
}

i.e. only binaries in the cgi-bin directory under the document root will be executed. To enable per-user cgi directories, add

$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" {
    cgi.assign = ("" => "")
}

to the lighttpd configuration file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文