Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

configuring apache for perl

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
I don't know where to post this really, but hopefully somebody can help. I've installed perl and apache, and both are working fine on their own, apache is serving up the pages, and if I use perl at the command line, it's returning the output I'm looking for. however, apache isn't processing my perl files correctly. I've put them in the cg-bin and tried using both the .pl and .cgi file extension but neither work. I've uncommented that ScriptAlias (as far as I can remmeber, that's what it's called) line in the apache configuration file so what's the problem? Is it my shebang line? the perl interpreter is at C:\perl\bin\ so my sheband line is #!C:/perl/bin/perl -- is that correct? can somebody tell me what I need to do so that perl works with apache and confirm if my shebang line is correct?

Thanks!!
 
Don't know if it will make any difference for you but for my system (Win98) my shebang had to be like this: #!C:/perl/bin/perl.exe.

Also, make sure that you put your scripts in the Apache cgi-bin.

There's always a better way...
 
Have a look at the FAQ section here FAQ#1 by missbarbell

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
You don't need the C: if this is running on a non-microsoft machine do a 'whereis perl' on a command line and you will see where it is located just put a #! before it. For example mine is located in /usr/bin/perl so at the top of all my cgi docs I have #!/usr/bin/perl Don't forget to add the content type line aswell. I think this is used so the browser recognizes it. So the top of your file should look something like this:

#!/usr/bin/perl <--- what ever your whereis perl command shows you

print &quot;Content-type:text/html\n\n&quot;;

use CGI;
use CGI::Carp qw(fatalsToBrowser);

And Your ScriptAlias should look something like this;

ScriptAlias /cgi-bin/ &quot;/var/
Hope this helps,

Emma
 
Unless you did something really strange with your apache install, you should have all the apache docs on your hard drive. I did the default install on my WinXP box and the apache software and docs went into,
C:\Program Files\Apache Group\Apache2
The docs are in,
C:\Program Files\Apache Group\Apache2\manual
There is a 'howto' directory containing a CGI howto,
C:\Program Files\Apache Group\Apache2\manual\howto
The CGI 'howto' file is 'cgi.html.en' on my machine. That file has a step by step of how to get your installation to do CGI. It even includes a very simple CGI program to test your setup.


OR, you can look at it on-line,

Apache has done a good job on these howto files. You can read through them, follow the instructions and you should be functional in less than an hour.

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
I just want to add, that you never ever want to put the full executable in the shebang line (#!C:/usr/bin/perl.exe). It instead should be: #!/usr/bin/perl. And yes, that will work on Windows. :)

I am Comptia A+ Certified
 
Micheal,

Why not the C: in the shebang line?

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
You have to associate the .cgi and .pl file extensions with the perl interpreter. You go and add a new file type. check windows help files.

It will solve your problem.

If you install activestate software it will do it for you.


haunter@battlestrata.com
 
Thanks everybody for your posts. The reason why it wasn't working was because I didn't have the
Code:
print &quot;Content-type:text/html\n\n&quot;;
in there. I had done all the file association etc.

well, thanks again everybody
 
PaulTEG: You can use the C: in the shebang if you want, but this way it will make your script easier to port over to *nix systems. Either way, you don't want that .exe at the end. Just C:\usr\bin\perl

I am Comptia A+ Certified
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top