How can I run my perl CGI script without apache? This is for testing purposes, so some kind of single-process server that processes only one request at time should be enough for me.
Plack::App::WrapCGI or Plack::App::CGIBin represent one way to do this (together with plackup
and the default single-threaded Plack HTTP server) but it's not running the CGIs in the context they really expect to be run in (a standalone process) so it's not entirely pretty (the same caveats apply as using modperl registry, more or less). I'm not aware of a pure-perl webserver that actually forks and runs CGI as CGI (nor a non-perl one that does CGI and requires zero config, although lighttpd comes close).
The reason why "are you using CGI.pm" is a relevant question is because if you haven't already started the application you might want to consider writing against pretty much anything else, e.g.
(in random order to hide my obvious favoritism) and gain the ability to easily run the same app as a standalone HTTP server, FastCGI, mod_perl app, or plain CGI if push comes to shove, and without the impedance mismatch that you get when writing to CGI.pm's interface
Since you mentioned in the comments that you're using CGI.pm, note that CGI.pm offers a range of options for running CGI scripts from the command line. See http://perldoc.perl.org/CGI.html#DEBUGGING. Even without CGI.pm, you could always just fake up the necessary environment variables and pipe in your file. Basically all you need to do to run a CGI from the command line is to set up
QUERY_STRING = blah=x&fu=bar
for GET methods, or
CONTENT_LENGTH = length of your file
for POST methods.
Script shoud be run as specific user and currently I do not want to setup
suexec
on testingapache
.
There is nothing preventing you from duplicating the requisite Apache configuration except for the user under which httpd
is going to be run, the interface/port to bind to and possibly the cgi-bin
directory and running a separate copy of httpd
(with the -f
option). That would be the safest way to test the application in the environment it is supposed run.
See Starting Apache:
it is possible to specify its location at run time using the
-f
command-line option as in/usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf
Get yourself a virtual machine and do whatever you like with it, including running apache. Duplicate as much as your target setup as you can.