Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

CGI on OpenBSD 5.6 httpd

by slamet (Initiate)
on Dec 21, 2014 at 11:08 UTC ( #1110948=perlquestion: print w/replies, xml ) Need Help??

slamet has asked for the wisdom of the Perl Monks concerning the following question:

I cannot find any documentation on how to get CGI going on OpenBSD 5.6 httpd. (Starting with 5.6, OpenBSD ships its own http daemon.) And I am a newbie with CGI. I have something like the following: hello
!#/usr/bin/perl print "Content type: text/html"; print "hello world";
I have done "chmod 755 hello", but when I call the address
curl localhost/hello
I got the whole file content, instead of just "hello world". I have poured over manpages for httpd and httpd.conf, but still cannot fix this. Many thanks for your help.

Replies are listed 'Best First'.
Re: CGI on OpenBSD 5.6 httpd
by poj (Abbot) on Dec 21, 2014 at 11:45 UTC

    Line 1 - Change !# to #!
    Line 2 - add \n\n

    #!/usr/bin/perl print "Content type: text/html\n\n"; print "hello world";
    Move the script to the cgi-bin folder and try curl localhost/cgi-bin/hello
    poj
Re: CGI on OpenBSD 5.6 httpd
by Corion (Pope) on Dec 21, 2014 at 11:24 UTC

    Are you sure that curl localhost/hello will contact your http server?

    I would try curl http://localhost/hello.

    Still, your webserver does not seem to be set up to treat hello as a CGI file. Maybe naming the file hello.cgi would help, if the webserver by default is set up to treat executable files named .cgi as programs producing output.

Re: CGI on OpenBSD 5.6 httpd
by Anonymous Monk on Dec 21, 2014 at 11:52 UTC
    I cannot find any documentation on how to get CGI going on OpenBSD 5.6 httpd.
    That's right, httpd by itself doesn't do plain cgi (only fastcgi). You need slowcgi(8).
Re: CGI on OpenBSD 5.6 httpd
by slamet (Initiate) on Jan 03, 2015 at 01:14 UTC

    Thanks for all the input. I fixed the typo on #!, renamed the file name, created cgi-bin dir under the chroot dir (and both have permission mode 755).

    Re comment on "curl localhost/..", what I meant was "curl http://ip address/..".

    Re slowcgi, according to the manpage, it actually is the implementation of fastcgi. :-)

    I suspect there is something on httpd.conf that I am missing, but I copied it from the manpage.

    prefork 2 server "default" { listen on egress port 80 } types { text/css css text/html htm html text/txt txt image/gif gif image/jpeg jpg jpeg image/png png application/javascript js application/xml xml }

    All in all, I am still stuck.

      Re slowcgi, according to the manpage, it actually is the implementation of fastcgi. :-)
      No.
      All in all, I am still stuck.
      httpd doesn't do CGI.

        Actually it does and it has a good sense of humour for the name.

        http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/httpd.conf.5

        Anyway, I just found this blog post. Thanks to all who responded to my inquiry.

        http://www.protoc.org/blog/2014/11/23/first-thoughts-on-the-new-openbsd-httpd-server/

        Cheers

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1110948]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2020-02-26 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (113 votes). Check out past polls.

    Notices?