Google Answers Logo
View Question
 
Q: getting mod_perl to work with nph scripts on Apache ( No Answer,   0 Comments )
Question  
Subject: getting mod_perl to work with nph scripts on Apache
Category: Computers > Programming
Asked by: bennetthaselton-ga
List Price: $40.00
Posted: 27 Jan 2006 21:28 PST
Expires: 03 Feb 2006 14:37 PST
Question ID: 438539
I am trying to get non-parsed-header scripts to work on an Apache
2.0.49 server with mod_perl installed.

I know that mod_perl is installed properly because the script:
http://www.stupidcensorship.com/cgi-bin/showall.pl
which prints all environment variables, shows:
"MOD_PERL:  mod_perl/1.99_12".
(I had thought mod_perl 1.x could not be installed with Apache 2.x,
however it was the default option with my hosting provider, and it
apparently worked -- bonus points if you can explain that one to
me...)

What I did was add these lines to my httpd.conf file:

	<Directory /var/www/cgi-bin>
	<IfModule mod_perl.c>
	<Files ~ (\.pl$)>
		SetHandler perl-script
		PerlHandler ModPerl::Registry
		Options ExecCGI
		allow from all
		PerlSendHeader Off
	</Files>
	</IfModule>
	<IfModule sapi_apache2.c>
		AddType text/plain .php .php4 .php3 .phtml
		php_admin_flag engine off
	</IfModule>
		Options -Includes -ExecCGI
	</Directory>

The problem is that non-parsed-header scripts are not working.  In
theory, if a non-parsed-header script prints "HTTP/1.1 200 OK\n" and
"Content-type: text/html\n\n" as its first lines, the server should
send that to the browser as the HTTP headers.  However, when I access
a script like:

http://www.stupidcensorship.com/cgi-bin/nph-send-200-ok-and-content-type-text-html-and-hello-world.pl

which sends those lines as output, what happens is that the Web server
apparently inserts a "text/plain" header, and then the browser just
displays the lines that I tried to print:

>>>
HTTP/1.1 200 OK
Content-type: text/html

hello world
>>>
(You'll want to view the URL above in Firefox; IE gets confused and
tries to save the file.)

How do I make the Web server actually take the lines that I'm
printing, and use them for the actual HTTP headers the way it's
supposed to?

Incidentally, I get the same result if I remove the "nph-" prefix from
the filename:
http://www.stupidcensorship.com/cgi-bin/send-200-ok-and-content-type-text-html-and-hello-world.pl
Is the probelm that the Web server is ignoring the nph- prefix and not
paying attention to the "non-parsed-header-ness" of the file?

I have read on a million different Web sites, "for nph scripts, set
PerlSendHeader to 'Off'", but as you can see in the excerpt from my
.conf file above, I've done that already and it didn't fix it.

p.s. added at the last minute: I also read that you have to add
"local($|)= 1 ;" to an nph script to make it work under mod_perl; I
tried that but still got the same results as above.

Clarification of Question by bennetthaselton-ga on 03 Feb 2006 14:37 PST
Incidentally the reason this wasn't working was because I was using
mod_perl version 1.99_12 and it didn't support NPH scripts until
version 1.99_13.  I'm now stuck trying to get the latest version 2.0.2
installed, but that's a different problem.  Just wanted to leave this
note in case it might help anyone else who comes along later looking
for a solution.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy