Greetings fellow programmers,
I'm a bit new here, so please be gentle.
Now the problem, I'm currently working on a dynamic web application running on WAGO PLC (750-8202) with embedded linux. Lighttpd is installed on the PLC itself. The goal is to monitor/edit I/O of the PLC from the web app.
After a lot of reasearch I found out I need to use CGI to communicate with my C applications that can return the information from the PLC that I need. I tried some simple hello world codes, but always with an error.
Here's my 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 )) )
}
And now a simple application I'm trying out written in C:
#include <stdio.h>
int main(void)
{
printf("Content-Type: text/plain;charset=us-ascii\n\n");
printf("Hello world\n\n");
return 0;
}
I call my application like this:
http://192.168.1.2/cgi-bin/foo.cgi
And only get a blank page. If I check error log, it gives me this error:
(mod_cgi.c.1341) cleaning up CGI: process died with signal 6
Can anyone point out where I'm making some kind of mistake? Or am I doing it all wrong? Is there some other, better way to communicate with C apps? I lost several days trying to figure it out and now I'm really let down. Any kind of help will be greatly appreciated.
Thanks a lot in advance and have a nice day!
SIGABRT, which can mean too much to tell without further information. Did you try to comment out the proxy stuff? Did you compilefoo.cgiwith the correct compiler for your silicone? Did you try a simple shell script (if a shell is available, of course) with just the lines#!/bin/shfollowed byecho Hello World!in it?