|
|
|
04-01-2002, 02:52 PM
|
Postid: 64845
|
|
Site Owner
Join Date: Oct 2000
Posts: 78
|
Apache configuration for .pl CGI scripts
I wanted to set up a test environment on my machine for writing some CGI scripts with Perl. I'm using WinXP pro. I've installed the win32 version of Apache. I'd like to be able to run perl scripts using the .pl extensions. I can't get it to work. Hopefully somebody here can offer some suggestions.
I'm led to believe by the documentation and some tips from various sites on the web that putting "AddHandler cgi-script .pl .cgi" in the directory definition of the ScriptAlias would do that.
I'm able use a perl script just fine as long as it has a .cgi extension, but when I try to access a .pl file IE tries to download it. What I have defined in the httpd.conf is:
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
<Directory "C:/Program Files/Apache Group/Apache/cgi-bin">
AddHandler cgi-script .pl .cgi
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
Any suggestions?
|
|
|
04-01-2002, 03:14 PM
|
Postid: 64846
|
|
Site Owner
Join Date: Aug 1999
Location: Metro Los Angeles Area
Posts: 7,398
|
I wonder if it is possible, that the spaces in your directory paths could be part of the problem?
I'm running Apache on Win98 at home, and am able to run Perl cgi out of the cgi-bin with the .pl extension.
My httpd.conf file contains the following lines:
ScriptAlias /cgi-bin/ "e:/Apache/cgi-bin/"
<Directory "e:/Apache/cgi-bin">
AllowOverride None
Options None
</Directory>
AddHandler cgi-script .cgi
AddHandler cgi-script .py
AddHandler cgi-script .pl
I do not have this line anywhere within my httpd.conf file:
Options +ExecCGI
I think you don't need it as long as you run your scripts out of the cgi-bin directory?
|
|
|
04-01-2002, 03:27 PM
|
Postid: 64847
|
|
Site Owner
Join Date: Jul 2001
Location: where the boat is: Chesapeake Bay
Posts: 702
|
The ScriptAlias line tells Apache that cgi-bin is -- well -- cgi-bin. I think (too lazy to check the Apache docs) that the Options ExecCGI lets you turn on the ability to run scripts from htaccess, which is not very useful since execution is on by default.
dave
|
|
|
04-01-2002, 03:58 PM
|
Postid: 64849
|
|
Site Owner
Join Date: Oct 2000
Posts: 78
|
Woo, thanks Shiela, you've come to my rescue again.
I uninstalled it and put it in a simpler path -- I had left it as that big ugly one just cuz it's the default and figured (not having done this before) the less I changed the better. Har!
I made my <Directory> look like yours and put the AddHandlers outside it and I can run the sample printenv.pl now (well after fixing the #!<perlpath>).
Thanks a bunch.
Aaron
|
|
|
04-01-2002, 04:11 PM
|
Postid: 64851
|
|
Site Owner
Join Date: Aug 1999
Location: Metro Los Angeles Area
Posts: 7,398
|
Cool. Glad it worked out.
I've found a number of programs that I run have difficulty with spaces in the path names. 
|
|
|
04-01-2002, 06:15 PM
|
Postid: 64872
|
|
Site Owner
Join Date: Oct 2000
Posts: 78
|
Well, turns out to not be the spaces. Guess I'm dumber than I originally thought.
I went off to learn how to install perl modules (DBI and DBD:mysql) and came back to the web server again a while later. I tried to hit that printenv.pl file again and it went back to the "Download File" thinger. It was asking me where I wanted to put "printenv.pl", so this time I just went ahead and saved it and looked at the contents. Doh, it wasn't the script, but the output from the script. It was working all along. I guess the server handles the plain text output from a .pl file differently from a .cgi? It works fine if I name the file .cgi. Or is it the browser in this case? Does the browser just accept plain text back off a .cgi source and not know what to expect off a .pl? If you know, feel free to enlighten me, just curious.
I put some html headers and tags around the output in the .pl and it worked like you would expect it to in the browser.
Aaron
|
|
|
04-01-2002, 08:03 PM
|
Postid: 64876
|
|
Site Owner
Join Date: Aug 1999
Location: Metro Los Angeles Area
Posts: 7,398
|
Quote:
|
Originally posted by Aaron O'Neil:It was asking me where I wanted to put "printenv.pl", so this time I just went ahead and saved it and looked at the contents. Doh, it wasn't the script, but the output from the script. It was working all along. I guess the server handles the plain text output from a .pl file differently from a .cgi? It works fine if I name the file .cgi. Or is it the browser in this case? Does the browser just accept plain text back off a .cgi source and not know what to expect off a .pl? If you know, feel free to enlighten me, just curious.[/i][/color]
|
I bet you are using IE for a browser, aren't you?
And you have installed Active State Perl, and let it set .pl as the registered extension for Perl files, and the registered application for that extension is Active State Perl. (So, tell me...are these guesses correct?)
If the above is correct...well, part of the problem is that IE tries to make guesses sometimes about the content of a file requested by the browser, based on the default applications registered to handle those files extensions on your machine. Sometimes that's OK, but in other cases, not.
I think that I don't have Active Sate Perl registered as default app on my system, because I like to be able to edit my Perl files with my text editor, and don't want them popping up and executing when I click on them.
You do have to be careful with IE. Anyhow, this is a good learning experience. Gives you something to be careful for, and watch out for, when you are writing scripts for your website. I should test in IE more. (Usually use Moz.)
|
|
|
04-01-2002, 08:15 PM
|
Postid: 64877
|
|
Site Owner
Join Date: Oct 2000
Posts: 78
|
Quote:
I bet you are using IE for a browser, aren't you?
And you have installed Active State Perl, and let it set .pl as the registered extension for Perl files, and the registered application for that extension is Active State Perl. (So, tell me...are these guesses correct?)
|
Hah, correct on all of the above. IE 6, Active State Perl, and I let it create the .pl file association.
Aaron
|
|
|
04-02-2002, 01:04 PM
|
Postid: 64931
|
|
Visitor
Join Date: Jun 2000
Location: Dallas, TX, USA
Posts: 90
|
One reason the printenv script isn't working is the top line of the script. Where is the #! looking for perl?
In mine, WinNT + Apache, it has:
Code:
#!C:\perl\bin\perl.exe
Maybe that would help. Or if you change the script in any other ways, list the changes here.
Bill
__________________
b at brilliantcorners.org
sometimes: [URL]http://brilliantcorners.org/[/URL]
soundtrack: [URL]http://thebigripoff.com/[/URL]
|
|
|
04-05-2002, 02:11 PM
|
Postid: 65193
|
|
Registered User
Join Date: Jan 2000
Posts: 237
|
Quote:
Originally posted by bturner:
One reason the printenv script isn't working is the top line of the script. Where is the #! looking for perl?
In mine, WinNT + Apache, it has:
Code:
#!C:\perl\bin\perl.exe
Maybe that would help. Or if you change the script in any other ways, list the changes here.
Bill
|
Yeah this was the problem on mine too when I installed Apache in Win2k. I know that it will work by using file associations (ignoring the #! in the script) but I couldn't get it working -- although I didn't really try that hard. The advantage is that you can configure your scripts to work under unix/linux (via the #! mechanism) and have them work under Micros~1 Windows by association so that the script doesn't have to change across platforms.
As it stands I have to make sure that I change all my scripts before uploading them which is kind of a pain.
I still remember the thrill of getting Apache running for the first time under Windows. Being able to do mod_rewrite's and using .htaccess, I was in heaven. I kept telling myself, "this is really Apache. No, seriously, the real Apache."
YMMV...
---
BenV
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 10:21 PM.
|
| |
|
|
|