Author |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Thu 09 Mar '06 10:24 Post subject: Getting Perl to Work on Apache Win32 - XP |
|
|
I have been struggling to get Perl to run scripts on a virtual host site. Perl is installed, runs scripts from command line & is in path.
I've put Perl scripts in Apache/cgi-bin/ and enabled via main CONF
<Directory "c:/Apache2/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
and set the 'SheBang' first script line
#!c:/perl/bin/perl.exe
But all I get on attempted execution
(http://www.mydomain.com/cgi-bin/ptesta.pl)
is a playback of the script in the browser window!
What am I missing??! There must be more directives needed...
Do I need Mod_Perl set up?
Any setup thoughts and/or example CONF sections appreciated.
- Art |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Thu 09 Mar '06 15:11 Post subject: |
|
|
Try to add:
AddHandler cgi-script pl
You do not need mod_Perl, in fact some scripts are not developed to work with mod_perl.
Steffen |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Thu 09 Mar '06 18:34 Post subject: |
|
|
Thnx Steffen - but
AddHandler cgi-script pl
(which I already had configured)
Did not do the trick either!!
Other possibilities? |
|
Back to top |
|
pnllan
Joined: 05 Dec 2005 Posts: 221
|
Posted: Thu 09 Mar '06 19:16 Post subject: |
|
|
Try this on your Options line:
Options +ExecCGI
Also use a DOT pl (.pl) in your AddHandler statement
. |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Fri 10 Mar '06 0:25 Post subject: |
|
|
Nope Steffen - those did not work either.
The browser (FireFox) just continues to show the script source!
Its like Apache is not executing Perl on the script before returning
output back to the browser.
I'm stumped. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
pnllan
Joined: 05 Dec 2005 Posts: 221
|
Posted: Fri 10 Mar '06 18:47 Post subject: |
|
|
Art,
Using the PLUS sign with ExecCGI did nothing you say
You mention FireFox use, is the behavior the same using IE? Just curious...
Really weird
You should not have to use Mod Perl to execute Perl scripts, but maybe it's time to give it a try.
. |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Fri 10 Mar '06 23:23 Post subject: |
|
|
Pnllan - Correct - +ExecCGI did not improve the sitaution.
FF simply plays the raw script code back in the browser.
IE executes Perl and quickly displays the generated HTML in a DOS box in the browser - not just the rendered page in the browser.
Note I'm testing this all out on my main client PC - not the actual server - which is where I want this all to go when it works.
Keep thinkin' ! |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Fri 10 Mar '06 23:35 Post subject: |
|
|
You can try:
ScriptAlias /cgi-bin/ "c:/Apache2/cgi-bin/"
Steffen |
|
Back to top |
|
pnllan
Joined: 05 Dec 2005 Posts: 221
|
Posted: Sat 11 Mar '06 0:17 Post subject: |
|
|
Is it just one script that is failing or everything?
If just one script - Will 'printenv.pl' in the cgi-bin folder do what it's supposed to do?
. |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sat 11 Mar '06 0:46 Post subject: |
|
|
Steffen - Yes have ScriptAlias /cgi-bin/ "c:/Apache2/cgi-bin/" in place.
pnllan - all scripts fail - just print script source - even printenv.pl, which runs from a DOS box just fine.
PS - should the shebang line use UNIX forward slashes("/") or Windows backwards slashes ("\") ? |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sat 11 Mar '06 0:47 Post subject: |
|
|
Re forward/backward slashes - I've tried both ways - no success. |
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Sat 11 Mar '06 3:13 Post subject: |
|
|
I read this post but had to sort of piece together what you likely have for your CGI configuration in the httpd.conf or what ever include file it may be contained within.
Here is an example of the CGI portion of one server I manage:
Code: | ################# CGI Permissions ##################
<Directory />
Options FollowSymLinks +IncludesNOEXEC
AddHandler cgi-script cgi pl pcgi
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>
<Directory x:/xxx/xxx/Perl/>
Options ExecCGI FollowSymLinks +IncludesNOEXEC
AuthName "Administration"
AuthType Basic
AuthUserFile x:/xxx/xxx/passwd
Order deny,allow
require valid-user
</Directory>
<Directory x:/xxx/stats/www/>
Options ExecCGI FollowSymLinks +IncludesNOEXEC
</Directory>
####################################################
|
So I am wondering what your config is looking like, of course you can post it but 'xxx' out any directories you wish not to display (not a big deal though on a secure server).
I always followed steps layed out by Steffen, for me there was never a problem. Hopefully we can figure it out though : )
--
Brian |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sat 11 Mar '06 4:31 Post subject: |
|
|
Brian - tried snippet of that - no soap!
I've posted my main Apache config + Extras & Perl test after it to
http://pastebin.com/595688
(with suitably smudged domain names to protect the innocent & naive - me!)
Maybe someone can see the error of my ways! |
|
Back to top |
|
pnllan
Joined: 05 Dec 2005 Posts: 221
|
Posted: Sat 11 Mar '06 8:21 Post subject: |
|
|
While you still have hair on your head, setup mod_perl and see if the script will run.
. |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sat 11 Mar '06 21:33 Post subject: |
|
|
pnllan wrote: | While you still have hair on your head, setup mod_perl and see if the script will run.
. |
OK - tried that - setup Mod_Perl - same effect !!
My scripts play source back in browser.
Hair getting thinner . . . !
What is the 'acid test' of Mod_Perl functioning correctly? |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sun 12 Mar '06 3:04 Post subject: |
|
|
pnllan wrote: | While you still have hair on your head, setup mod_perl and see if the script will run.
. |
Tried that. Same effect - simple playback in browser. Not execution by Perl.
My scripts play source back in browser.
Hair getting thinner . . . !
What is the 'acid test' of Mod_Perl functioning correctly? |
|
Back to top |
|
ArtM
Joined: 23 Feb 2006 Posts: 59 Location: Bedford NS Canada
|
Posted: Sun 12 Mar '06 6:25 Post subject: |
|
|
Found it !
Seems I had
LoadModule cgi_module modules/mod_cgi.so
commented out. Dunno why.
Uncommented & scripts now execute & playback properly in browser. |
|
Back to top |
|
holziusa
Joined: 02 Jan 2008 Posts: 48
|
Posted: Tue 22 Apr '08 9:04 Post subject: |
|
|
hi ArtM,
i am as new as a daily sunrise when it comes to apache, but try this for kicks add this line
ScriptInterpreterSource registry
worked for me in latest ver apache,perl,mod_perl
also try this in hello.pl
"print "Content-type: text/html\n\n";
print "Hello World\n";"
now get this trying to migrate from a more user friendly server to
i assumed the world lives in apache server,
it took me 40 hrs to extract this info from available resources,
very sad indeed not something to look forward to given the reputation
of the apache server.
btw: 40% of insight came from this forum. thanks all contributor |
|
Back to top |
|