Newbie - Setting up PERL and cgi-bin woes

Alles, was Perl betrifft, kann hier besprochen werden.

Newbie - Setting up PERL and cgi-bin woes

Postby destudent » 25. November 2009 05:43

Hello to the community. I am a newbie and want to know how to setup PERL and run PERL with XAMPP. I tried putting a perl script, very simple one, in cgi-bin directory but when I go to http://localhost/cgi-bin/1.pl , it gives me a 500 error.

Also if I make a directory in htdocs (remember that cgi-bin is not in htdocs) and put my file in it and run it (http://localhost/perl/1.pl) it gives me an error in error log of Apache as :

Options ExecCGI is off in this directory: /Applications/xampp/xamppfiles/htdocs/perl/1.pl

I am running XAMPP on Mac OSX. My source code is this:

Code: Select all
#!usr/local/bin/perl
print "Content-type: text/plain; charset=iso-8859-1\n\n";
print "hello";



Perhaps I am not doing something right. I also have a question that how can these files be run when they are not under htdocs?
Please note that I Googled this a lot but found no solution. I also have correct permissions on all directories and files (755). I was wondering if I need to create a cgi-bin under htdocs?

Please help
Thanks.
destudent
 
Posts: 2
Joined: 25. November 2009 05:35

Re: Newbie - Setting up PERL and cgi-bin woes

Postby Nobbie » 25. November 2009 11:29

destudent wrote: it gives me a 500 error.


And what gives it in error log of Apache?

destudent wrote:Also if I make a directory in htdocs (remember that cgi-bin is not in htdocs) and put my file in it and run it (http://localhost/perl/1.pl) it gives me an error in error log of Apache as :

Options ExecCGI is off in this directory: /Applications/xampp/xamppfiles/htdocs/perl/1.pl


Seems to be honestly true - you should apply "Options ExecCGI" to your htdocs (DocumentRoot) folder in httpd.conf and restart Apache

destudent wrote:I am running XAMPP on Mac OSX. My source code is this:

Code: Select all
#!usr/local/bin/perl
print "Content-type: text/plain; charset=iso-8859-1\n\n";
print "hello";



Is there a valid Perl Interpreter installed at /usr/local/bin/perl? If not, your Shebang line is wrong, it must point to a perl binary.

destudent wrote:Perhaps I am not doing something right. I also have a question that how can these files be run when they are not under htdocs?


Define a "ScriptAlias" Directive for the desired folder (you will find an example in httpd.conf for /cgi-bin, which is actually not under htdocs).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Newbie - Setting up PERL and cgi-bin woes

Postby destudent » 25. November 2009 14:09

Nobbie wrote:And what gives it in error log of Apache?

this is Apache's error log after I moved the cgi-bin to htdocs. Although I used to think that the server CAN serve something thats not even in the htdocs but anyway, I would just be happy to run PERL to say the least.
Code: Select all
[Wed Nov 25 07:59:02 2009] [error] [client ::1] (2)No such file or directory: exec of '/Applications/xampp/xamppfiles/cgi-bin/1.pl' failed
[Wed Nov 25 07:59:02 2009] [error] [client ::1] Premature end of script headers: 1.pl
[Wed Nov 25 07:59:02 2009] [error] [client ::1] File does not exist: /Applications/xampp/xamppfiles/htdocs/favicon.ico, referer: http://localhost/cgi-bin/1.pl


Nobbie wrote:Seems to be honestly true - you should apply "Options ExecCGI" to your htdocs (DocumentRoot) folder in httpd.conf and restart Apache

I have this:
Code: Select all
ScriptAlias /cgi-bin/ "/Applications/xampp/xamppfiles/htdocs/cgi-bin/"

</IfModule>

#
# "/Applications/xampp/xamppfiles/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/Applications/xampp/xamppfiles/htdocs/cgi-bin">
    #AllowOverride None
    #Options None
   AllowOverride All
   Options ExecCGI
    Order allow,deny
    Allow from all
   AddHandler cgi-script .pl
</Directory>




destudent wrote:I am running XAMPP on Mac OSX. My source code is this:

Code: Select all
#!usr/local/bin/perl
print "Content-type: text/plain; charset=iso-8859-1\n\n";
print "hello";



Nobbie wrote:Is there a valid Perl Interpreter installed at /usr/local/bin/perl? If not, your Shebang line is wrong, it must point to a perl binary.


A which perl command told me that perl is installed under /usr/bin/perl. But I do not know if XAMPP can access that. ......

Update: It CANNOT access that. I used a PERL interpreter that came with XAMPP and it worked. lol

destudent wrote:Perhaps I am not doing something right. I also have a question that how can these files be run when they are not under htdocs?


Define a "ScriptAlias" Directive for the desired folder (you will find an example in httpd.conf for /cgi-bin, which is actually not under htdocs).[/quote]


----Thanks a lot. Your reply made me drifted me in the right direction. THanks. --AJ
destudent
 
Posts: 2
Joined: 25. November 2009 05:35


Return to Perl

Who is online

Users browsing this forum: No registered users and 5 guests