500 在 lighttpd 中调用 "C" 编写的 CGI 时的内部服务器



服务器是Linux,运行lighttpd测试代码在";C";如下(test.c(

#include <stdio.h>
int main ()
{
printf ("Welcome to CGI");
return 0;
}

我编译了代码来生成CGI,就像下面的一样

gcc test.c -o test.cgi

我把生成test.cgi文件放在web/cgi-bin/文件夹中,在从浏览器/cgi-bin/test.cgi 访问它时显示以下错误

500 Internal Server Error

日志文件由组成

2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.628) Path         : /filesys/web/cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.652) -- logical -> physical
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.653) Doc-Root     : /filesys/web/
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.654) Basedir      : /filesys/web/
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.655) Rel-Path     : /cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.656) Path         : /filesys/web/cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.668) -- handling physical path
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.669) Path         : /filesys/web/cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.676) -- handling subrequest
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.677) Path         : /filesys/web/cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.678) URI          : /cgi-bin/test.cgi
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/response.c.679) Pathinfo     :
2021-01-04 04:56:32: (../../lighttpd-1.4.53/src/mod_access.c.177) -- mod_access_uri_handler called

正如@basile starynkevitch所指出的,您的程序输出不符合(非常简单的(CGI协议。然而,lighttpd仍将处理此问题。

您没有共享lighttpd.conf(lighttpd -f /etc/lighttpd/lighttpd.conf -p(,所以我猜您没有正确配置lighttpd-mod_cgi来处理请求。

运行web服务器的用户帐户应该可以对web/cgi-bin/所在的路径和文件进行文件系统访问。

如果这对你来说从来都不起作用,那么也要检查SELinux是否阻止了CGI的执行。

我解决了这个问题,所以发布了解决方案。基本上,在与GCC不兼容的目标嵌入式设备中执行时存在交叉编译问题。

最新更新