Sometimes I want to fire up a websever for a particular directory just to test some scripts. It is a real pain to set up apache for this as it involves editing the httpd.conf file or moving the test files to another directory.

I have searched for some small webservers that can do CGI and can be started with just a command line. I have found a partial answer in mini_httpd. Running something like mini_httpd -p 8080 -c '**.pl' will start a server which uses the current directory as its base, it will listen on port 8080 and will treat anything ending in .pl as a CGI script.

Unfortunately there does not appear to be sensible error logging so a special line is required at the top of each script:

#!/usr/bin/perl open STDERR, ">>errors" if $ENV{SERVER_SOFTWARE} =~ m/^mini_httpd/; use strict; use warnings; use CGI::Carp; use CGI; warn "This is a warning"; print CGI->header; print "Hello"; print "<br>$_ : $ENV{$_}\n" for keys %ENV;

Does anyone have a solution to this problem. I want to start a server from the command line that lets me test scripts. Obviously this server will be very simple, only just enough for CGI scripts.

This is the list of servers I scanned to find mini_httpd.

--tidiness is the memory loss of environmental mnemonics


In reply to Simple command line web server for running cgis. by EvdB

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.