Reputation: 4179
The server is Linux and running lighttpd The test code in "C" is like below (test.c)
#include <stdio.h>
int main ()
{
printf ("Welcome to CGI");
return 0;
}
I compiled the code to generate CGI like below
gcc test.c -o test.cgi
I put the generate test.cgi file in web/cgi-bin/ folder and it showing following error while accessing it fron browser /cgi-bin/test.cgi
500 Internal Server Error
The log file consists of
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
Upvotes: 1
Views: 1186
Reputation: 4179
I got it resolved, so posting the solution. Basically, there is cross-compilation issue to execute in the target embedded device which was not compatible with GCC.
Upvotes: 0
Reputation: 2379
As noted by @basile-starynkevitch, your program output is not compliant with the (very simple) CGI protocol. However, lighttpd will still handle that.
You did not share your lighttpd.conf (lighttpd -f /etc/lighttpd/lighttpd.conf -p
), so I am guessing that you did not properly configure lighttpd mod_cgi to handle the request.
The user account under which the web server is running should have filesystem access to the path and files wherever your web/cgi-bin/
is located.
If this has never worked for you, then also check to see if SELinux is blocking the CGI execution.
Upvotes: 2