Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Updated: CGI scripts work, but Perl don't... |
|
Author |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 06 May '08 21:36 Post subject: Updated: CGI scripts work, but Perl don't... |
|
|
Hi, I just setup my Apache 2 server on my Win2k Machine and configured it to run cgi and perl scripts as stated in previous threads. Given below is the changes I have made to the httpd.conf file:
LoadModule cgi_module modules/mod_cgi.so
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
#!c:/perl/bin/perl.exe
AddHandler cgi-script .cgi .pl
LoadModule perl_module modules/mod_perl.so
The problem I am currently facing is pretty peculiar:
I can successfully execute scripts with cgi extension located in cgi-bin directory on Internet Explorer. However The same cgi-script returns unparsed data on Firefox as follows
<html><head><title>this is the title</title></head><body>This is the body</body></html>
Further more, I am unable to execute scripts with .pl extension in either firefox or IE. I did try with the default HTML-1.pl and printenv.pl files but to no avail. I keep getting the Error on IE and on Firefox.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@xx.xx.xx.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
and on Firefox, it's even more peculiar:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
admin@xx.xx.xx.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
And my Windows Path is configured.
Can someone please guide me about the same?
Last edited by bugz on Tue 06 May '08 22:33; edited 3 times in total |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 06 May '08 21:56 Post subject: |
|
|
Do you have as first line in your script ?
#!c:/perl/bin/perl.exe
Sometimes you have to restart your box to make the Windows PATH active. |
|
Back to top |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 06 May '08 22:02 Post subject: |
|
|
Yes I do, and I have been working with perl on my box since past year so it's pretty active. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 06 May '08 22:17 Post subject: |
|
|
What does the Apache error.log say ?
Using the same Perl version as before ?
When I read you start post, I see two times
AddHandler cgi-script .cgi .pl
BTW. when using only the Apache2.2/cgi-bin for your scripts, you do not need AddHandler cgi-script .cgi .pl |
|
Back to top |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 06 May '08 22:30 Post subject: Updated: Dunno what changed |
|
|
Something Changed and I don't know what.
The following script works on IE and Firefox
html3.pl
Code: |
#!c:/perl/bin/perl.exe
print "Content-type: text/HTML\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>Hello World!</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Hello World!</H2>\n";
print "</BODY>\n";
print "</HTML>\n";
exit (0); |
so does the following:
The following script works on Firefox, but on IE, it asks if i wish to download it.
sample.pl
Code: | #!c:/perl/bin/perl.exe
print "Content-type: text/plain\n\n";
print "mod_perl 2.0 rocks!\n";
|
Again, the printenv.pl file from cgi-bin folder executes in Firefox, but on IE, it executes the CMD and runs on it.
printenv.pl
Code: | #!c:/perl/bin/perl.exe
##
## printenv -- demo CGI program which just prints its environment
##
print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}
|
And finally the cgi script now runs on both IE and Firefox
Code: | #!c:/perl/bin/perl.exe
print "Content-type: text/html\n\n";
print "<html><head><title>this is the title</title></head><body>This is the body</body></html>";
|
Any explanations please?
Last edited by bugz on Tue 06 May '08 22:46; edited 3 times in total |
|
Back to top |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 06 May '08 22:35 Post subject: |
|
|
I did put in place as when i work later, I would not place my cgi scripts in cgi-bin alone.
Also It was a typo to have to twice in my question. Corrected it. |
|
Back to top |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 06 May '08 22:50 Post subject: Update: Works....Almost |
|
|
So I think i resolved most of the errors when i included the mod_perl.
But I am still wondering when the content-type: text/plain
1. why the IE asks me to download the script
or
2. Just executes it as in the case of printenv.pl |
|
Back to top |
|
bugz
Joined: 06 May 2008 Posts: 10 Location: Worcester, MA, USA
|
Posted: Tue 26 Aug '08 18:11 Post subject: Installation Problems |
|
|
Hi Everyone,
It's me again
I just installed Apache 2.2 on a new WinXp SP2 box which has perl version 5.6.1
I made the following changes to httpd.conf as i have posted in my first post
ie.
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
I did not find the shebang line in the httpd.conf and added the same as well.
#!c:/perl/bin/perl.exe
I tried without it and i still get the same error.
The ScriptAlias line was already uncommented.
The load cgi_module like was already uncommented.
And I uncommented the line
AddHandler cgi-script .cgi
(I know from past posts that Apache 2.2 doesn't need AddHandler line to be uncommented. So i tried that way too and still get the same error)
The server runs when started and the index page loads properly. However when i try to run the cgi files from cgi-bin directory, i get the
"500 Internal Server Error"
The Error Log says:
[Tue Aug 26 11:59:38 2008] [error] [client 127.0.0.1] (OS 5)Access is denied. : Failed to open cgi file C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/Search.cgi for testing
[Tue Aug 26 11:59:38 2008] [error] [client 127.0.0.1] (OS 5)Access is denied. : don't know how to spawn child process: C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/Search.cgi
The File SearchPage.cgi has the first line as:
#!c:/perl/bin/perl.exe
So What am i doing wrong now? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 26 Aug '08 19:03 Post subject: |
|
|
For setting up mod_perl correctly see our tutorial jump to the Mod_perl part. |
|
Back to top |
|
|
|
|
|
|