WebFaction
Community site: login faq

I installed Date::Calc per help from WebFaction support:

cpan o conf makepl_arg 'PREFIX=~/lib/perl5 LIB=~/lib/perl5/lib INSTALLMAN1DIR=~/lib/perl5/man1 INSTALLMAN3DIR=~/lib/perl5/man3' install Date::Calc

So when I check my CGI on the command line, it seems fine. But when I hit it from the browser, I get a 500 server error. As far as I can tell, there's no good error message in the logs. The only thing I saw in my error_*.logs was [Sat Aug 04 23:57:59 2012] [error] [client 138.210.196.115] Premature end of script headers:

Any tips, clues or help would be appreciated. Thanks very much.

asked 04 Aug '12, 20:35

anorris
111
accept rate: 0%

So I got it to work by adding:

use lib '/home/[MYHOME]/lib/perl5/lib';

But would be nice if there were a way to configure it so I don't have to add this to all the CGIs I have that use this library.

(04 Aug '12, 22:52) anorris

Sorry, but there's no way to do this out-of-the-box. Specifically, CGI scripts are run by Apache via suExec, and suExec (for security reasons) prevents modification of the environment before the script is executed. It is expected that the script will perform whichever modifications to the environment are necessary. There are a couple of common paradigms you'll see in practice:

  1. A single entry point, such as an "index.php" file in the case of PHP, through which all requests are initially filtered. This entry point then sets the appropriate environment variables. Kohana (for example) uses a "bootstrap.php" file exactly for this purpose.
  2. A common included bootstrap function at the beginning of all CGI scripts which runs "common code", and you would set @INC there, along with the configuration of any other global settings.

In your case, method 2 seems to be the most straightforward solution.

permanent link

answered 05 Aug '12, 02:22

ryans ♦♦
5.0k103960
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×20
×1

question asked: 04 Aug '12, 20:35

question was seen: 2,503 times

last updated: 05 Aug '12, 02:22

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM