gpt4 book ai didi

c - Lighttpd - 尝试通过 CGI 运行 C 应用程序时出错

转载 作者:行者123 更新时间:2023-11-30 14:57:47 27 4
gpt4 key购买 nike

各位程序员大家好,

我是新来的,所以请温柔点。

现在的问题是,我目前正在开发一个在带有嵌入式 Linux 的 WAGO PLC (750-8202) 上运行的动态 Web 应用程序。 Lighttpd 安装在 PLC 本身上。目标是从 Web 应用程序监控/编辑 PLC 的 I/O。

经过大量研究,我发现我需要使用 CGI 与我的 C 应用程序进行通信,该应用程序可以从 PLC 返回我需要的信息。我尝试了一些简单的 hello world 代码,但总是出错。

这是我的 lighttpd.conf

# Common configuration values.
server.document-root = "/var/www"
server.username = "www"
server.groupname = "www"
server.tag = "lighttpd"
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"

index-file.names = ( "index.html", "index.php" )
server.modules = (
"mod_access",
"mod_accesslog",
"mod_cgi",
"mod_fastcgi",
"mod_rewrite",
"mod_redirect",
"mod_auth",
"mod_proxy"
)

include "mode.conf"
include "mime_types.conf"
include "mod_fastcgi.conf"
include "auth.conf"
include "redirect_test.conf"

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

cgi.assign = (
".cgi" => ""
)
url.rewrite-once = (
# Codesys3 webvisu forces the browser to come out with POST requests to the root context.
# Move that to the /webvisu/ context so it goes through the proxy 8000.
"^/WebVisuV3.bin" => "/webvisu/WebVisuV3.bin",
# Redirect all http[s]://<ip>/rest/ URL's to the RESTful API Example "/rest/index.php'
"^(?:.*)/rest/(.*)" => "/rest/index.php/$1"
)

# Transfer all http[s]://<ip>/webvisu/ URL's to the proxy server on port 8000.
# That is, all codesys webvisu traffic goes through the proxy.
#$HTTP["url"] =~ "^/webvisu/.*" {
# proxy.server = ("" => (( "host" => "127.0.0.1", "port" => proxy_port )) )
#}

# Activate proxy server on port 8000. Sends all requests from the browser to
# the codesys webserver (localhost:8080).
$SERVER["socket"] == "127.0.0.1:" + proxy_port {
url.rewrite-once = (
"^/webvisu/$" => "/webvisu.htm",
"^/webvisu/(.*)" => "/$1"
),
proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8080 )) )
}

现在我正在尝试用 C 编写一个简单的应用程序:

#include <stdio.h> 
int main(void)
{
printf("Content-Type: text/plain;charset=us-ascii\n\n");
printf("Hello world\n\n");
return 0;
}

我这样称呼我的应用程序:

http://192.168.1.2/cgi-bin/foo.cgi

并且只得到一个空白页。如果我检查错误日志,它会给出以下错误:

(mod_cgi.c.1341) cleaning up CGI: process died with signal 6 

谁能指出我在哪里犯了某种错误?还是我做的都是错的?还有其他更好的方式与 C 应用程序进行通信吗?我花了好几天时间试图弄清楚,现在我真的很失望。任何形式的帮助将不胜感激。

提前非常感谢,祝你有美好的一天!

最佳答案

感谢 deamentiaemundi,我成功了。我使用了错误的编译器,PLC有一个ARM处理器,需要使用Wago提供的工具-ptxdist来编译代码。

关于c - Lighttpd - 尝试通过 CGI 运行 C 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43690607/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com