Project

General

Profile

I can't get cgi's to execute from browsers, lighttpd server running on the Pi

Added by pijimh over 5 years ago

Running lighttpd on Raspberry Pi 3B, Raspbian Jessie, upgraded to latest. It serves plain html to browsers just fine.

My html files are in /var/www/html, bash cgi's in /var/www/html/cgi-bin. Permissions are all +rwx for the directories and files.
I've tried cgi file and directory ownerships of root, pi, various others.

Lighttpd error logs are enabled (I think) but they are empty.

Lighttpd configuration in /etc/lighttpd/lighttpd.conf:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_cgi",
    "mod_compress",
     "mod_redirect",
#       "mod_rewrite",
)
server.document-root        = "/var/www/html" 
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log" 
server.breakagelog        = "/var/log/lighttpd/breakage.log" 
server.pid-file             = "/var/run/lighttpd.pid" 
server.username             = "www-data" 
server.groupname            = "www-data" 
server.port                 = 80

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

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.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

My cgi files in /var/www/html/cgi-bin:
-rwxrwxrwx 1 pi pi 53 Oct 16 22:14 led_off.cgi
-rwxrwxrwx 1 pi pi 97 Oct 18 08:01 led_on.cgi

My cgi file led_on.cgi:
#!/bin/bash
echo -e "Content-type: text/html\n\n"
gpio -g mode 17 out
gpio -g write 17 1
exit(0)

I can manually run the cgi's from the Pi command line and the LED on Pi GPIO 17 goes on and off fine.
But cgi's don't get executed when accessed by the browsers, browsers just show the cgi file content.
I assume the cgi files are in the right place since the browsers can see them, just won't execute the cgi's.

I've tried firefox, chrome and edge browsers, they all see the cgi files but just show:
(browsing http://192.168.1.38//cgi-bin/led_on.cgi)

#!/bin/bash
echo -e "Content-type: text/html\n\n"
gpio -g mode 17 out
gpio -g write 17 1
exit(0)

This Pi is successfully running a camera server, implemented as per:
http://www.toptechboy.com/tutorial/low- ... ip-camera/

Could the camera server php be getting in the way of my cgi's operation?

Thanks mucho,
Jim


Replies (8)

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by gstrauss over 5 years ago

It does not look like you have configured CGI. See Docs_ModCGI

Run lighttpd -p -f /etc/lighttpd/lighttpd.conf to see your whole config as lighttpd sees it. You did not show the whole config above. The includes are missing. If you don't see a cgi.assign directive, then you have not configured lighttpd to serve any CGI.

Separately, if you think the other camera server is interfering, temporarily shut it down and see if you are still serving the files.

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by pijimh over 5 years ago

Thank you gstrauss.

I see the full config file using lighttpd -p -f /etc/lighttpd/lighttpd.conf

The fastcgi.server has a reference to cgi in the mimetype.assign=(... section, tail shown below, but no cgi.assign.

In Docs_ModCGI Module: mod_cgi I see the cgi.assign example:
------
cgi.assign
file-extensions that are handled by a CGI program
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
------

But I don't know how to add the cgi.assign=... to the full config.
Is the full config an editable file?
Where in the full connfig do I add the cgi.assign?

Thanks, Jim

-------------------------------
From my full config:
(snip)

        ".wvx"      => "video/x-ms-wvx",
        # 510
        ".avi"      => "video/x-msvideo",
        ".movie"    => "video/x-sgi-movie",
        ".mpv"      => "video/x-matroska",
        ".mkv"      => "video/x-matroska",
        ".ice"      => "x-conference/x-cooltalk",
        # 515
        ".sisx"     => "x-epoc/x-sisx-app",
        ".vrm"      => "x-world/x-vrml",
        # 517
    )

    fastcgi.server                 = (
        ".php" => (
            (
                "bin-path"              => "/usr/bin/php-cgi",
                "socket"                => "/var/run/lighttpd/php.socket",
                "max-procs"             => 1,
                "bin-environment"       => (
                    "PHP_FCGI_CHILDREN"     => "4",
                    "PHP_FCGI_MAX_REQUESTS" => "10000",
                    # 2
                ),
                "bin-copy-environment"  => ("PATH", "SHELL", "USER"),
                # 5
                "broken-scriptfilename" => "enable",
                # 6
            ),
        ),
    )
    alias.url                      = (
        "/javascript" => "/usr/share/javascript",
    )

    $SERVER["socket"] == "[::]:80" {
        # block 1

    } # end of $SERVER["socket"] == "[::]:80" 

    $HTTP["url"] =~ "^/cgi-bin/" {
        # block 2
        cgi.assign = (
            "" => "",
        )

-------------------------------

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by pijimh over 5 years ago

With lighty-enable-mod it looks like the cgi mod is already enabled:

At this point I'm going to build a new clean machine (OS) and start fresh.

Thanks, Jim

pi@raspberrypi_8:/var/www/html/cgi-bin $ lighty-enable-mod
Disabled modules: accesslog auth debian-doc dir-listing evasive evhost expire extforward flv-streaming no-www proxy rrdtool simple-vhost ssi ssl status userdir usertrack
Enabled modules: cgi fastcgi fastcgi-php javascript-alias

Enable module: cgi
already enabled
Run /etc/init.d/lighttpd force-reload to enable changes
pi@raspberrypi_8:/var/www/html/cgi-bin $ sudo /etc/init.d/lighttpd force-reload
[ ok ] Reloading lighttpd configuration (via systemctl): lighttpd.service.
pi@raspberrypi_8:/var/www/html/cgi-bin $

Here's my full config:
---------------------

config {
    var.PID                        = 8463
    var.CWD                        = "/var/www/html/cgi-bin" 
    server.modules                 = (
        "mod_indexfile",
        "mod_access",
        "mod_alias",
        "mod_cgi",
        "mod_compress",
        "mod_redirect",
        "mod_cgi",
        "mod_fastcgi",
        "mod_dirlisting",
        "mod_staticfile",
        # 10
    )
    server.document-root           = "/var/www/html" 
    server.upload-dirs             = ("/var/cache/lighttpd/uploads")
    server.errorlog                = "/var/log/lighttpd/error.log" 
    server.breakagelog             = "/var/log/lighttpd/breakage.log" 
    server.pid-file                = "/var/run/lighttpd.pid" 
    server.username                = "www-data" 
    server.groupname               = "www-data" 
    server.port                    = 80
    index-file.names               = ("index.php", "index.html", "index.lighttpd.html")
    url.access-deny                = ("~", ".inc")
    static-file.exclude-extensions = (".php", ".pl", ".fcgi")
    static-file.include-extensions = (".cgi")
    compress.cache-dir             = "/var/cache/lighttpd/compress/" 
    compress.filetype              = ("application/javascript", "text/css", "text/html", "text/plain")
    mimetype.assign                = (
        ".ez"       => "application/andrew-inset",
        ".anx"      => "application/annodex",
        ".atom"     => "application/atom+xml",
        ".atomcat"  => "application/atomcat+xml",
        ".atomsrv"  => "application/atomserv+xml",
        # 5
        ".lin"      => "application/bbolin",
        ".cu"       => "application/cu-seeme",
        ".davmount" => "application/davmount+xml",
        ".dcm"      => "application/dicom",
        ".tsp"      => "application/dsptype",
        # 10
        ".es"       => "application/ecmascript",
        ".otf"      => "application/font-sfnt",
        ".ttf"      => "application/font-sfnt",
        ".pfr"      => "application/font-tdpfr",
        ".woff"     => "application/font-woff",
        # 15
        ".spl"      => "application/futuresplash",
        ".gz"       => "application/gzip",
        ".hta"      => "application/hta",
        ".jar"      => "application/java-archive",
        ".ser"      => "application/java-serialized-object",
        # 20
        ".class"    => "application/java-vm",
        ".js"       => "application/javascript",
        ".json"     => "application/json",
        ".m3g"      => "application/m3g",
        ".hqx"      => "application/mac-binhex40",
        # 25
        ".cpt"      => "application/mac-compactpro",
        ".nb"       => "application/mathematica",
        ".nbp"      => "application/mathematica",
        ".mbox"     => "application/mbox",
        ".mdb"      => "application/msaccess",
        # 30
        ".doc"      => "application/msword",
        ".dot"      => "application/msword",
        ".mxf"      => "application/mxf",
        ".bin"      => "application/octet-stream",
        ".oda"      => "application/oda",
        # 35
        ".opf"      => "application/oebps-package+xml",
        ".ogx"      => "application/ogg",
        ".one"      => "application/onenote",
        ".onetoc2"  => "application/onenote",
        ".onetmp"   => "application/onenote",
        # 40
        ".onepkg"   => "application/onenote",
        ".pdf"      => "application/pdf",
        ".pgp"      => "application/pgp-encrypted",
        ".key"      => "application/pgp-keys",
        ".sig"      => "application/pgp-signature",
        # 45
        ".prf"      => "application/pics-rules",
        ".ps"       => "application/postscript",
        ".ai"       => "application/postscript",
        ".eps"      => "application/postscript",
        ".epsi"     => "application/postscript",
        # 50
        ".epsf"     => "application/postscript",
        ".eps2"     => "application/postscript",
        ".eps3"     => "application/postscript",
        ".rar"      => "application/rar",
        ".rdf"      => "application/rdf+xml",
        # 55
        ".rtf"      => "application/rtf",
        ".stl"      => "application/sla",
        ".smi"      => "application/smil+xml",
        ".smil"     => "application/smil+xml",
        ".xhtml"    => "application/xhtml+xml",
        # 60
        ".xht"      => "application/xhtml+xml",
        ".xml"      => "application/xml",
        ".xsd"      => "application/xml",
        ".xsl"      => "application/xslt+xml",
        ".xslt"     => "application/xslt+xml",
        # 65
        ".xspf"     => "application/xspf+xml",
        ".zip"      => "application/zip",
        ".apk"      => "application/vnd.android.package-archive",
        ".cdy"      => "application/vnd.cinderella",
        ".deb"      => "application/vnd.debian.binary-package",
        # 70
        ".ddeb"     => "application/vnd.debian.binary-package",
        ".udeb"     => "application/vnd.debian.binary-package",
        ".sfd"      => "application/vnd.font-fontforge-sfd",
        ".kml"      => "application/vnd.google-earth.kml+xml",
        ".kmz"      => "application/vnd.google-earth.kmz",
        # 75
        ".xul"      => "application/vnd.mozilla.xul+xml",
        ".xls"      => "application/vnd.ms-excel",
        ".xlb"      => "application/vnd.ms-excel",
        ".xlt"      => "application/vnd.ms-excel",
        ".eot"      => "application/vnd.ms-fontobject",
        # 80
        ".thmx"     => "application/vnd.ms-officetheme",
        ".cat"      => "application/vnd.ms-pki.seccat",
        ".ppt"      => "application/vnd.ms-powerpoint",
        ".pps"      => "application/vnd.ms-powerpoint",
        ".odc"      => "application/vnd.oasis.opendocument.chart",
        # 85
        ".odb"      => "application/vnd.oasis.opendocument.database",
        ".odf"      => "application/vnd.oasis.opendocument.formula",
        ".odg"      => "application/vnd.oasis.opendocument.graphics",
        ".otg"      => "application/vnd.oasis.opendocument.graphics-template",
        ".odi"      => "application/vnd.oasis.opendocument.image",
        # 90
        ".odp"      => "application/vnd.oasis.opendocument.presentation",
        ".otp"      => "application/vnd.oasis.opendocument.presentation-template",
        ".ods"      => "application/vnd.oasis.opendocument.spreadsheet",
        ".ots"      => "application/vnd.oasis.opendocument.spreadsheet-template",
        ".odt"      => "application/vnd.oasis.opendocument.text",
        # 95
        ".odm"      => "application/vnd.oasis.opendocument.text-master",
        ".ott"      => "application/vnd.oasis.opendocument.text-template",
        ".oth"      => "application/vnd.oasis.opendocument.text-web",
        ".pptx"     => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
        ".sldx"     => "application/vnd.openxmlformats-officedocument.presentationml.slide",
        # 100
        ".ppsx"     => "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
        ".potx"     => "application/vnd.openxmlformats-officedocument.presentationml.template",
        ".xlsx"     => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        ".xltx"     => "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
        ".docx"     => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
        # 105
        ".dotx"     => "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
        ".cod"      => "application/vnd.rim.cod",
        ".mmf"      => "application/vnd.smaf",
        ".sdc"      => "application/vnd.stardivision.calc",
        ".sds"      => "application/vnd.stardivision.chart",
        # 110
        ".sda"      => "application/vnd.stardivision.draw",
        ".sdd"      => "application/vnd.stardivision.impress",
        ".sdf"      => "application/vnd.stardivision.math",
        ".sdw"      => "application/vnd.stardivision.writer",
        ".sgl"      => "application/vnd.stardivision.writer-global",
        # 115
        ".sxc"      => "application/vnd.sun.xml.calc",
        ".stc"      => "application/vnd.sun.xml.calc.template",
        ".sxd"      => "application/vnd.sun.xml.draw",
        ".std"      => "application/vnd.sun.xml.draw.template",
        ".sxi"      => "application/vnd.sun.xml.impress",
        # 120
        ".sti"      => "application/vnd.sun.xml.impress.template",
        ".sxm"      => "application/vnd.sun.xml.math",
        ".sxw"      => "application/vnd.sun.xml.writer",
        ".sxg"      => "application/vnd.sun.xml.writer.global",
        ".stw"      => "application/vnd.sun.xml.writer.template",
        # 125
        ".sis"      => "application/vnd.symbian.install",
        ".cap"      => "application/vnd.tcpdump.pcap",
        ".pcap"     => "application/vnd.tcpdump.pcap",
        ".vsd"      => "application/vnd.visio",
        ".vst"      => "application/vnd.visio",
        # 130
        ".vsw"      => "application/vnd.visio",
        ".vss"      => "application/vnd.visio",
        ".wbxml"    => "application/vnd.wap.wbxml",
        ".wmlc"     => "application/vnd.wap.wmlc",
        ".wmlsc"    => "application/vnd.wap.wmlscriptc",
        # 135
        ".wpd"      => "application/vnd.wordperfect",
        ".wp5"      => "application/vnd.wordperfect5.1",
        ".wk"       => "application/x-123",
        ".7z"       => "application/x-7z-compressed",
        ".abw"      => "application/x-abiword",
        # 140
        ".dmg"      => "application/x-apple-diskimage",
        ".bcpio"    => "application/x-bcpio",
        ".torrent"  => "application/x-bittorrent",
        ".cab"      => "application/x-cab",
        ".cbr"      => "application/x-cbr",
        # 145
        ".cbz"      => "application/x-cbz",
        ".cdf"      => "application/x-cdf",
        ".cda"      => "application/x-cdf",
        ".vcd"      => "application/x-cdlink",
        ".pgn"      => "application/x-chess-pgn",
        # 150
        ".mph"      => "application/x-comsol",
        ".cpio"     => "application/x-cpio",
        ".csh"      => "application/x-csh",
        ".dcr"      => "application/x-director",
        ".dir"      => "application/x-director",
        # 155
        ".dxr"      => "application/x-director",
        ".dms"      => "application/x-dms",
        ".wad"      => "application/x-doom",
        ".dvi"      => "application/x-dvi",
        ".pfa"      => "application/x-font",
        # 160
        ".pfb"      => "application/x-font",
        ".gsf"      => "application/x-font",
        ".mm"       => "application/x-freemind",
        ".gan"      => "application/x-ganttproject",
        ".gnumeric" => "application/x-gnumeric",
        # 165
        ".sgf"      => "application/x-go-sgf",
        ".gcf"      => "application/x-graphing-calculator",
        ".gtar"     => "application/x-gtar",
        ".tgz"      => "application/x-gtar-compressed",
        ".taz"      => "application/x-gtar-compressed",
        # 170
        ".hdf"      => "application/x-hdf",
        ".hwp"      => "application/x-hwp",
        ".ica"      => "application/x-ica",
        ".info"     => "application/x-info",
        ".ins"      => "application/x-internet-signup",
        # 175
        ".isp"      => "application/x-internet-signup",
        ".iii"      => "application/x-iphone",
        ".iso"      => "application/x-iso9660-image",
        ".jam"      => "application/x-jam",
        ".jnlp"     => "application/x-java-jnlp-file",
        # 180
        ".jmz"      => "application/x-jmol",
        ".chrt"     => "application/x-kchart",
        ".kil"      => "application/x-killustrator",
        ".skp"      => "application/x-koan",
        ".skd"      => "application/x-koan",
        # 185
        ".skt"      => "application/x-koan",
        ".skm"      => "application/x-koan",
        ".kpr"      => "application/x-kpresenter",
        ".kpt"      => "application/x-kpresenter",
        ".ksp"      => "application/x-kspread",
        # 190
        ".kwd"      => "application/x-kword",
        ".kwt"      => "application/x-kword",
        ".latex"    => "application/x-latex",
        ".lha"      => "application/x-lha",
        ".lyx"      => "application/x-lyx",
        # 195
        ".lzh"      => "application/x-lzh",
        ".lzx"      => "application/x-lzx",
        ".frm"      => "application/x-maker",
        ".maker"    => "application/x-maker",
        ".frame"    => "application/x-maker",
        # 200
        ".fm"       => "application/x-maker",
        ".fb"       => "application/x-maker",
        ".book"     => "application/x-maker",
        ".fbdoc"    => "application/x-maker",
        ".mif"      => "application/x-mif",
        # 205
        ".wmd"      => "application/x-ms-wmd",
        ".wmz"      => "application/x-ms-wmz",
        ".com"      => "application/x-msdos-program",
        ".exe"      => "application/x-msdos-program",
        ".bat"      => "application/x-msdos-program",
        # 210
        ".dll"      => "application/x-msdos-program",
        ".msi"      => "application/x-msi",
        ".nc"       => "application/x-netcdf",
        ".pac"      => "application/x-ns-proxy-autoconfig",
        ".nwc"      => "application/x-nwc",
        # 215
        ".o"        => "application/x-object",
        ".oza"      => "application/x-oz-application",
        ".p7r"      => "application/x-pkcs7-certreqresp",
        ".crl"      => "application/x-pkcs7-crl",
        ".pyc"      => "application/x-python-code",
        # 220
        ".pyo"      => "application/x-python-code",
        ".qgs"      => "application/x-qgis",
        ".shp"      => "application/x-qgis",
        ".shx"      => "application/x-qgis",
        ".qtl"      => "application/x-quicktimeplayer",
        # 225
        ".rdp"      => "application/x-rdp",
        ".rpm"      => "application/x-redhat-package-manager",
        ".rss"      => "application/x-rss+xml",
        ".rb"       => "application/x-ruby",
        ".sci"      => "application/x-scilab",
        # 230
        ".sce"      => "application/x-scilab",
        ".xcos"     => "application/x-scilab-xcos",
        ".sh"       => "application/x-sh",
        ".shar"     => "application/x-shar",
        ".swf"      => "application/x-shockwave-flash",
        # 235
        ".swfl"     => "application/x-shockwave-flash",
        ".scr"      => "application/x-silverlight",
        ".sql"      => "application/x-sql",
        ".sit"      => "application/x-stuffit",
        ".sitx"     => "application/x-stuffit",
        # 240
        ".sv4cpio"  => "application/x-sv4cpio",
        ".sv4crc"   => "application/x-sv4crc",
        ".tar"      => "application/x-tar",
        ".tcl"      => "application/x-tcl",
        ".gf"       => "application/x-tex-gf",
        # 245
        ".pk"       => "application/x-tex-pk",
        ".texinfo"  => "application/x-texinfo",
        ".texi"     => "application/x-texinfo",
        ".t"        => "application/x-troff",
        ".tr"       => "application/x-troff",
        # 250
        ".roff"     => "application/x-troff",
        ".man"      => "application/x-troff-man",
        ".me"       => "application/x-troff-me",
        ".ms"       => "application/x-troff-ms",
        ".ustar"    => "application/x-ustar",
        # 255
        ".src"      => "application/x-wais-source",
        ".wz"       => "application/x-wingz",
        ".crt"      => "application/x-x509-ca-cert",
        ".xcf"      => "application/x-xcf",
        ".fig"      => "application/x-xfig",
        # 260
        ".xpi"      => "application/x-xpinstall",
        ".xz"       => "application/x-xz",
        ".amr"      => "audio/amr",
        ".awb"      => "audio/amr-wb",
        ".axa"      => "audio/annodex",
        # 265
        ".au"       => "audio/basic",
        ".snd"      => "audio/basic",
        ".csd"      => "audio/csound",
        ".orc"      => "audio/csound",
        ".sco"      => "audio/csound",
        # 270
        ".flac"     => "audio/flac",
        ".mid"      => "audio/midi",
        ".midi"     => "audio/midi",
        ".kar"      => "audio/midi",
        ".mpga"     => "audio/mpeg",
        # 275
        ".mpega"    => "audio/mpeg",
        ".mp2"      => "audio/mpeg",
        ".mp3"      => "audio/mpeg",
        ".m4a"      => "audio/mpeg",
        ".m3u"      => "audio/mpegurl",
        # 280
        ".oga"      => "audio/ogg",
        ".ogg"      => "audio/ogg",
        ".opus"     => "audio/ogg",
        ".spx"      => "audio/ogg",
        ".sid"      => "audio/prs.sid",
        # 285
        ".aif"      => "audio/x-aiff",
        ".aiff"     => "audio/x-aiff",
        ".aifc"     => "audio/x-aiff",
        ".gsm"      => "audio/x-gsm",
        ".wma"      => "audio/x-ms-wma",
        # 290
        ".wax"      => "audio/x-ms-wax",
        ".ra"       => "audio/x-pn-realaudio",
        ".rm"       => "audio/x-pn-realaudio",
        ".ram"      => "audio/x-pn-realaudio",
        ".pls"      => "audio/x-scpls",
        # 295
        ".sd2"      => "audio/x-sd2",
        ".wav"      => "audio/x-wav",
        ".alc"      => "chemical/x-alchemy",
        ".cac"      => "chemical/x-cache",
        ".cache"    => "chemical/x-cache",
        # 300
        ".csf"      => "chemical/x-cache-csf",
        ".cbin"     => "chemical/x-cactvs-binary",
        ".cascii"   => "chemical/x-cactvs-binary",
        ".ctab"     => "chemical/x-cactvs-binary",
        ".cdx"      => "chemical/x-cdx",
        # 305
        ".cer"      => "chemical/x-cerius",
        ".c3d"      => "chemical/x-chem3d",
        ".chm"      => "chemical/x-chemdraw",
        ".cif"      => "chemical/x-cif",
        ".cmdf"     => "chemical/x-cmdf",
        # 310
        ".cml"      => "chemical/x-cml",
        ".cpa"      => "chemical/x-compass",
        ".bsd"      => "chemical/x-crossfire",
        ".csml"     => "chemical/x-csml",
        ".csm"      => "chemical/x-csml",
        # 315
        ".ctx"      => "chemical/x-ctx",
        ".cxf"      => "chemical/x-cxf",
        ".cef"      => "chemical/x-cxf",
        ".emb"      => "chemical/x-embl-dl-nucleotide",
        ".embl"     => "chemical/x-embl-dl-nucleotide",
        # 320
        ".spc"      => "chemical/x-galactic-spc",
        ".inp"      => "chemical/x-gamess-input",
        ".gam"      => "chemical/x-gamess-input",
        ".gamin"    => "chemical/x-gamess-input",
        ".fch"      => "chemical/x-gaussian-checkpoint",
        # 325
        ".fchk"     => "chemical/x-gaussian-checkpoint",
        ".cub"      => "chemical/x-gaussian-cube",
        ".gau"      => "chemical/x-gaussian-input",
        ".gjc"      => "chemical/x-gaussian-input",
        ".gjf"      => "chemical/x-gaussian-input",
        # 330
        ".gal"      => "chemical/x-gaussian-log",
        ".gcg"      => "chemical/x-gcg8-sequence",
        ".gen"      => "chemical/x-genbank",
        ".hin"      => "chemical/x-hin",
        ".istr"     => "chemical/x-isostar",
        # 335
        ".ist"      => "chemical/x-isostar",
        ".jdx"      => "chemical/x-jcamp-dx",
        ".dx"       => "chemical/x-jcamp-dx",
        ".kin"      => "chemical/x-kinemage",
        ".mcm"      => "chemical/x-macmolecule",
        # 340
        ".mmd"      => "chemical/x-macromodel-input",
        ".mmod"     => "chemical/x-macromodel-input",
        ".mol"      => "chemical/x-mdl-molfile",
        ".rd"       => "chemical/x-mdl-rdfile",
        ".rxn"      => "chemical/x-mdl-rxnfile",
        # 345
        ".sd"       => "chemical/x-mdl-sdfile",
        ".tgf"      => "chemical/x-mdl-tgf",
        ".mcif"     => "chemical/x-mmcif",
        ".mol2"     => "chemical/x-mol2",
        ".gpt"      => "chemical/x-mopac-graph",
        # 350
        ".mop"      => "chemical/x-mopac-input",
        ".mopcrt"   => "chemical/x-mopac-input",
        ".mpc"      => "chemical/x-mopac-input",
        ".zmt"      => "chemical/x-mopac-input",
        ".moo"      => "chemical/x-mopac-out",
        # 355
        ".mvb"      => "chemical/x-mopac-vib",
        ".asn"      => "chemical/x-ncbi-asn1",
        ".prt"      => "chemical/x-ncbi-asn1-ascii",
        ".ent"      => "chemical/x-ncbi-asn1-ascii",
        ".val"      => "chemical/x-ncbi-asn1-binary",
        # 360
        ".aso"      => "chemical/x-ncbi-asn1-binary",
        ".pdb"      => "chemical/x-pdb",
        ".ros"      => "chemical/x-rosdal",
        ".sw"       => "chemical/x-swissprot",
        ".vms"      => "chemical/x-vamas-iso14976",
        # 365
        ".vmd"      => "chemical/x-vmd",
        ".xtel"     => "chemical/x-xtel",
        ".xyz"      => "chemical/x-xyz",
        ".gif"      => "image/gif",
        ".ief"      => "image/ief",
        # 370
        ".jp2"      => "image/jp2",
        ".jpg2"     => "image/jp2",
        ".jpeg"     => "image/jpeg",
        ".jpg"      => "image/jpeg",
        ".jpe"      => "image/jpeg",
        # 375
        ".jpm"      => "image/jpm",
        ".jpx"      => "image/jpx",
        ".jpf"      => "image/jpx",
        ".pcx"      => "image/pcx",
        ".png"      => "image/png",
        # 380
        ".svg"      => "image/svg+xml",
        ".svgz"     => "image/svg+xml",
        ".tiff"     => "image/tiff",
        ".tif"      => "image/tiff",
        ".djvu"     => "image/vnd.djvu",
        # 385
        ".djv"      => "image/vnd.djvu",
        ".ico"      => "image/vnd.microsoft.icon",
        ".wbmp"     => "image/vnd.wap.wbmp",
        ".cr2"      => "image/x-canon-cr2",
        ".crw"      => "image/x-canon-crw",
        # 390
        ".ras"      => "image/x-cmu-raster",
        ".cdr"      => "image/x-coreldraw",
        ".pat"      => "image/x-coreldrawpattern",
        ".cdt"      => "image/x-coreldrawtemplate",
        ".erf"      => "image/x-epson-erf",
        # 395
        ".art"      => "image/x-jg",
        ".jng"      => "image/x-jng",
        ".bmp"      => "image/x-ms-bmp",
        ".nef"      => "image/x-nikon-nef",
        ".orf"      => "image/x-olympus-orf",
        # 400
        ".psd"      => "image/x-photoshop",
        ".pnm"      => "image/x-portable-anymap",
        ".pbm"      => "image/x-portable-bitmap",
        ".pgm"      => "image/x-portable-graymap",
        ".ppm"      => "image/x-portable-pixmap",
        # 405
        ".rgb"      => "image/x-rgb",
        ".xbm"      => "image/x-xbitmap",
        ".xpm"      => "image/x-xpixmap",
        ".xwd"      => "image/x-xwindowdump",
        ".eml"      => "message/rfc822",
        # 410
        ".igs"      => "model/iges",
        ".iges"     => "model/iges",
        ".msh"      => "model/mesh",
        ".mesh"     => "model/mesh",
        ".silo"     => "model/mesh",
        # 415
        ".wrl"      => "model/vrml",
        ".vrml"     => "model/vrml",
        ".x3dv"     => "model/x3d+vrml",
        ".x3d"      => "model/x3d+xml",
        ".x3db"     => "model/x3d+binary",
        # 420
        ".appcache" => "text/cache-manifest",
        ".ics"      => "text/calendar",
        ".icz"      => "text/calendar",
        ".css"      => "text/css",
        ".csv"      => "text/csv",
        # 425
        ".323"      => "text/h323",
        ".html"     => "text/html",
        ".htm"      => "text/html",
        ".shtml"    => "text/html",
        ".uls"      => "text/iuls",
        # 430
        ".mml"      => "text/mathml",
        ".asc"      => "text/plain",
        ".txt"      => "text/plain",
        ".text"     => "text/plain",
        ".pot"      => "text/plain",
        # 435
        ".brf"      => "text/plain",
        ".srt"      => "text/plain",
        ".rtx"      => "text/richtext",
        ".sct"      => "text/scriptlet",
        ".wsc"      => "text/scriptlet",
        # 440
        ".tm"       => "text/texmacs",
        ".tsv"      => "text/tab-separated-values",
        ".ttl"      => "text/turtle",
        ".vcf"      => "text/vcard",
        ".vcard"    => "text/vcard",
        # 445
        ".jad"      => "text/vnd.sun.j2me.app-descriptor",
        ".wml"      => "text/vnd.wap.wml",
        ".wmls"     => "text/vnd.wap.wmlscript",
        ".bib"      => "text/x-bibtex",
        ".boo"      => "text/x-boo",
        # 450
        ".h++"      => "text/x-c++hdr",
        ".hpp"      => "text/x-c++hdr",
        ".hxx"      => "text/x-c++hdr",
        ".hh"       => "text/x-c++hdr",
        ".c++"      => "text/x-c++src",
        # 455
        ".cpp"      => "text/x-c++src",
        ".cxx"      => "text/x-c++src",
        ".cc"       => "text/x-c++src",
        ".h"        => "text/x-chdr",
        ".htc"      => "text/x-component",
        # 460
        ".c"        => "text/x-csrc",
        ".d"        => "text/x-dsrc",
        ".diff"     => "text/x-diff",
        ".patch"    => "text/x-diff",
        ".hs"       => "text/x-haskell",
        # 465
        ".java"     => "text/x-java",
        ".ly"       => "text/x-lilypond",
        ".lhs"      => "text/x-literate-haskell",
        ".moc"      => "text/x-moc",
        ".p"        => "text/x-pascal",
        # 470
        ".pas"      => "text/x-pascal",
        ".gcd"      => "text/x-pcs-gcd",
        ".pl"       => "text/x-perl",
        ".pm"       => "text/x-perl",
        ".py"       => "text/x-python",
        # 475
        ".scala"    => "text/x-scala",
        ".etx"      => "text/x-setext",
        ".sfv"      => "text/x-sfv",
        ".tk"       => "text/x-tcl",
        ".tex"      => "text/x-tex",
        # 480
        ".ltx"      => "text/x-tex",
        ".sty"      => "text/x-tex",
        ".cls"      => "text/x-tex",
        ".vcs"      => "text/x-vcalendar",
        ".3gp"      => "video/3gpp",
        # 485
        ".axv"      => "video/annodex",
        ".dl"       => "video/dl",
        ".dif"      => "video/dv",
        ".dv"       => "video/dv",
        ".fli"      => "video/fli",
        # 490
        ".gl"       => "video/gl",
        ".mpeg"     => "video/mpeg",
        ".mpg"      => "video/mpeg",
        ".mpe"      => "video/mpeg",
        ".mp4"      => "video/mp4",
        # 495
        ".qt"       => "video/quicktime",
        ".mov"      => "video/quicktime",
        ".ogv"      => "video/ogg",
        ".webm"     => "video/webm",
        ".mxu"      => "video/vnd.mpegurl",
        # 500
        ".flv"      => "video/x-flv",
        ".lsf"      => "video/x-la-asf",
        ".lsx"      => "video/x-la-asf",
        ".mng"      => "video/x-mng",
        ".asf"      => "video/x-ms-asf",
        # 505
        ".asx"      => "video/x-ms-asf",
        ".wm"       => "video/x-ms-wm",
        ".wmv"      => "video/x-ms-wmv",
        ".wmx"      => "video/x-ms-wmx",
        ".wvx"      => "video/x-ms-wvx",
        # 510
        ".avi"      => "video/x-msvideo",
        ".movie"    => "video/x-sgi-movie",
        ".mpv"      => "video/x-matroska",
        ".mkv"      => "video/x-matroska",
        ".ice"      => "x-conference/x-cooltalk",
        # 515
        ".sisx"     => "x-epoc/x-sisx-app",
        ".vrm"      => "x-world/x-vrml",
        # 517
    )
    fastcgi.server                 = (
        ".php" => (
            (
                "bin-path"              => "/usr/bin/php-cgi",
                "socket"                => "/var/run/lighttpd/php.socket",
                "max-procs"             => 1,
                "bin-environment"       => (
                    "PHP_FCGI_CHILDREN"     => "4",
                    "PHP_FCGI_MAX_REQUESTS" => "10000",
                    # 2
                ),
                "bin-copy-environment"  => ("PATH", "SHELL", "USER"),
                # 5
                "broken-scriptfilename" => "enable",
                # 6
            ),
        ),
    )
    alias.url                      = (
        "/javascript" => "/usr/share/javascript",
    )

    $SERVER["socket"] == "[::]:80" {
        # block 1

    } # end of $SERVER["socket"] == "[::]:80" 

    $HTTP["url"] =~ "^/cgi-bin/" {
        # block 2
        cgi.assign = (
            "" => "",
        )

    } # end of $HTTP["url"] =~ "^/cgi-bin/" 
}

-------------------------------

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by pijimh over 5 years ago

Hello gstrauss,

I have built a clean minimum install machine RPI 3B running Jessie, latest updates and upgrades, still no joy. CGIs in /var/www/html/cgi-bin don't get
executed. Browsers show /var/www/html content properly.

Please explain the difference between what editors see at /etc/lighttpd/lighttpd.conf and the "full configuration" that is shown with lighttpd -p -f
etc/lighttpd/lighttpd.conf. My full configuration is shown above.

If the full configuration is the one lighttpd uses, how do I modify it?

/var/log/lighttpd/error.log shows:
2018-10-21 21:04:24: (server.c.1558) server stopped by UID = 0 PID = 1
2018-10-21 21:04:32: (log.c.164) server started
2018-10-21 22:03:10: (server.c.1558) server stopped by UID = 0 PID = 1
2018-10-21 22:03:22: (log.c.164) server started
2018-10-21 22:31:23: (mod_cgi.c.601) cgi died, pid: 3079
2018-10-21 22:31:28: (mod_cgi.c.601) cgi died, pid: 3082
2018-10-21 22:45:13: (mod_cgi.c.601) cgi died, pid: 3959

I can supply a VNC link to that machine if you would like to examine it, if there is a private method to get the link to you.

Thanks much,
Jim

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by gstrauss over 5 years ago

2018-10-21 22:31:23: (mod_cgi.c.601) cgi died, pid: 3079
2018-10-21 22:31:28: (mod_cgi.c.601) cgi died, pid: 3082
2018-10-21 22:45:13: (mod_cgi.c.601) cgi died, pid: 3959

Why don't you start with a "Hello World!" CGI program and get that working?

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by pijimh over 5 years ago

Hello,

  • hello.cgi file:
    #!/bin/bash
    echo "Content-type: text/html"
    echo ""
    echo '<html>'
    echo '<head>'
    echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
    echo '<title>Hello World</title>'
    echo '</head>'
    echo '<body>'
    echo '<h1>Hello World</h1><p>'
    echo 'Using Bash<p>'
    free | grep Mem
    echo '</body>'
    echo '</html>'
    exit 0
  • cgi-bin contents:
    pi@raspberrypi_8:/var/www/html/cgi-bin $ ls -al
    total 48
    drwxrwxrwx 2 pi pi 4096 Oct 19 23:36 .
    drwxrwxrwx 4 root root 4096 Oct 17 00:21 ..
    -rwxrwxrwx 1 root root 322 Oct 18 08:02 hello.cgi
    -rwxrwxrwx 1 pi pi 53 Oct 16 22:14 led_off.cgi
    -rwxrwxrwx 1 pi pi 97 Oct 18 08:01 led_on.cgi
    pi@raspberrypi_8:/var/www/html/cgi-bin $

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '<title>Hello World</title>'
echo '</head>'
echo '<body>'
echo '<h1>Hello World</h1><p>'
echo 'Using Bash<p>'
free | grep Mem
echo '</body>'
echo '</html>'
exit 0

These results are the same from two RPi3Bs running Jessie, one system is a new minimal install.
Please let me know what other information may be helpful.

Thanks, Jim

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by gstrauss over 5 years ago

Basic troubleshooting 101: minimize your config and get things working doing as little as possible, and then slowly add things back, testing along the way, until you find what breaks.

lighttpd runs CGI just fine. Your setup has something that is wrong.

Start small. Really. I mean it. Much smaller than you currently think.

It is telling that your "hello world" CGI is trying to impress someone (definitely not me) by being more than a few lines of code.

#!/bin/sh
echo "Status: 200" 
echo "Content-Type: text/plain" 
echo
echo "Hello World!" 

Even the above could be shorter, but I'll leave that as an example of portable CGI.

RE: I can't get cgi's to execute from browsers, lighttpd server running on the Pi - Added by pijimh over 5 years ago

Hello gstrauss,

I'm sure that lighttpd works well, that my setup is at fault, and that asking for help isn't likely to impress anyone. I found the "simple" cgi example by searching for "simple cgi example". My mistake, but I did learn something! When you get a chance, please use your favorite browser to search for "condescension".

Thanks, Jim

    (1-8/8)