HTTP-404 has asked for the wisdom of the Perl Monks concerning the following question:

I've been messing with Apache config to get Perl/CGI running for 3 weeks no luck but is it possable to make web server in perl that supports CGI can HTTP::Daemon handle it thnx

Replies are listed 'Best First'.
Re: CGI web server in Perl
by chromatic (Archbishop) on Mar 24, 2001 at 11:39 UTC
    The best resource I've found is The Idiot's Guide to Solving Perl CGI Problems. Don't let the title throw you.

    Barring that, yes, it's possible to make a web server in Perl that supports CGI. I used HTTP::Daemon. It's called Jellybean. As merlyn says, standard CGI scripts are really pretty dull once you have a web server that understands Perl.

    But it does work for that.

Re: CGI web server in Perl
by merlyn (Sage) on Mar 24, 2001 at 05:46 UTC
    Yes, it's possible. It's a small matter of programming. But until you tell us what the "no luck" part is, it's hard to help you any further.

    By CGI, I presume you mean "forks a separate process to run a separate (possibly non-perl) program, passing the right things on standard in and in the environment, and looking for certain responses on standard out and for the exit status". That's what CGI is. Do you mean that differently?

    But, if you're doing that, you might as well use a standard webserver, which will certainly be much more efficient than an HTTP::Daemon-created Perlserver. The advantage to the Perlserver is that it doesn't need to fork for CGI!

    -- Randal L. Schwartz, Perl hacker

Re: CGI web server in Perl
by arturo (Vicar) on Mar 24, 2001 at 04:54 UTC

    Really, it shouldn't be that hard in Apache, on whatever platform you're running it on (*nix-slanted instructions are here).

    You're probably missing something easily fixed, but which has to work right; it's hardly worth the effort to reinvent this wheel. CGI is a protocol that has to be implemented in a certain way to work right (e.g. the user input has to get to the right place). Although I'm pretty sure one could implement something like it in HTTP::Daemon, unless you're looking for a wacky project stick with the tried-and-true solution (one could, in the same sense, replicate the Empire State building in downtown London all by oneself).

    Try putting something like this in your httpd.conf file; if it doesn't work, say what's not working (500 error? Just shows the source code?) and look at your webserver's error_log.

    # might need to be /apache/cgi-bin -> points to a directory on your ha +rd drive Alias /cgi-bin c:\apache\cgi-bin <Location /cgi-bin> AllowOverride None Order allow,deny Allow from all Options +ExecCGI </Location>

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: CGI web server in Perl
by strredwolf (Chaplain) on Mar 25, 2001 at 04:03 UTC
    Yep, it's been done. There's a Perl program called mhttpd that I use for testing. You'll have to search for it in Google, I don't have the URL on me.

    --
    $Stalag99{"URL"}="http://stalag99.keenspace.com";