I'm making a portable installation of Apache to run Bugzilla. This installation has a portable version of Perl and it's the one I want mod_cgi to use. However, mod_cgi doesn't have any way to configure the intended binary (or binaries per file type), so it depends on the shebang to know what to execute.

My problem is this: Bugzilla's perl files have a shebang that points to #!/usr/bin/perl -T and since I'm on Windows (unfortunately nothing can be done about this) and I want to use the particular Perl distribution intended for the server, I need to modify the shebangs.

I know I can just run a perl script beforehand and just replace all the shebangs with ones pointing to the proper binary, but I would prefer a solution that is more robust. I thought of filters and mod_lua, but Apache and its modules seem to have no hooks or directives that allow processing files before they're sent to the cgi process. They can only process requests sent by a client or the final output before it's sent back to the client.

Is there any way to process a file, using Apache or a module, before it is sent to the cgi process?

Is there a way to make the cgi process think that my intended perl is in fact in /usr/bin/perl?

  • Programs don't get "sent" to the CGI process; details of the request get passed to the CGI process when it starts up, and it's up to the process to do the needful. – womble Dec 16 '15 at 21:36

1st question: No, not easily. And the couple of ways I know of doing this always cause issues 'down-the-road'

2nd question: Yes. You can simple create a 'Drive':\usr\bin folder, and install the needed version of Perl there. Note that 'Drive' needs to be equal to the drive letter that your Apache service is running on. Then your scripts will use this Perl version without needing to be changed.

| improve this answer | |
  • Thanks for the answer. I sorted the issue preliminarily by mass replacing the shebang lines, since that seems to be more practical and simple. For those who come here looking for a way out: apparently mod_perl2 can work on windows but I haven't tested it with bugzilla on windows apache. If mod_perl2 does work, then it's simply a matter of wrapping httpd in a batch file or script that changes the environment httpd sees so that PATH points to the portable perl. Also, mod_perl2 seems to allow some powerful apache scripting, perhaps even preprocessing files but I'm not sure. – mechalynx Jan 4 '16 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.