Project

General

Profile

[Solved] how running a CGI written in C

Added by freeor about 1 month ago

I followed this link https://www.acmesystems.it/foxg20_cgi,
But after I log in, http://cgi-bin/hello.cgi shows that the web page cannot work. Do you have a routine for this C program cgi?


Replies (4)

RE: how running a CGI written in C - Added by freeor about 1 month ago

freeor wrote:

I followed this link https://www.acmesystems.it/foxg20_cgi,
But after I log in, http://cgi-bin/hello.cgi shows that the web page cannot work. Do you have a routine for this C program cgi?

lighttpd/1.4.53 (ssl) - a light and fast webserver

google

OS: linux

RE: how running a CGI written in C - Added by gstrauss about 1 month ago

But after I log in, http://cgi-bin/hello.cgi shows that the web page cannot work.

You seem to be deficient in some areas. "the web page cannot work" is a childish "description". For someone attempting to write in C, you ought to know better.

How to get support - please read

The acmesystems.it page you referenced is not bad, but you were sloppy reading it. The Final Test example has three slashes http:///cgi-bin/hello.cgi and would have been better written as http://127.0.0.1/cgi-bin/hello.cgi or http://localhost/cgi-bin/hello.cgi

RE: [Solved] how running a CGI written in C - Added by freeor about 1 month ago

 cd   /var/www/cgi-bin/
deepin@deepin-PC:/var/www/cgi-bin$ ls
hello.cgi
web   http://localhost/cgi-bin/hello.cgi   404 not found

lightthpd.conf 

server.modules = ("mod_cgi")

server.document-root        = "/var/www/html" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 80

# strict parsing and normalization of URL for consistency and security
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
# (might need to explicitly set "url-path-2f-decode" = "disable" 
#  if a specific application is encoding URLs inside url-path)
server.http-parseopts = (
  "header-strict"           => "enable",# default
  "host-strict"             => "enable",# default
  "host-normalize"          => "enable",# default
  "url-normalize-unreserved"=> "enable",# recommended highly
  "url-normalize-required"  => "enable",# recommended
  "url-ctrls-reject"        => "enable",# recommended
  "url-path-2f-decode"      => "enable",# recommended highly (unless breaks app)
 #"url-path-2f-reject"      => "enable",
  "url-path-dotseg-remove"  => "enable",# recommended highly (unless breaks app)
 #"url-path-dotseg-reject"  => "enable",
 #"url-query-20-plus"       => "enable",# consistency in query string
)

index-file.names            = ( "index.php", "index.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".cgi", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/" 
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.conf.pl" 
include "/etc/lighttpd/conf-enabled/*.conf" 

#server.compat-module-load   = "disable" 
server.modules += (
    "mod_compress",
    "mod_dirlisting",
    "mod_staticfile",
)

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

cgi.assign      = (
        ".cgi"  => "" 
)

RE: [Solved] how running a CGI written in C - Added by gstrauss about 1 month ago

server.document-root = "/var/www/html" and /var/www/cgi-bin do not overlap.

When lighttpd looks for /cgi-bin/hello.cgi, it looks for /var/www/html/cgi-bin/hello.cgi in your config and does not find hello.cgi there.

Read mod_cgi doc more carefully and look at the alias.url use. See also mod_alias doc.

    (1-4/4)