Pampa
asked on
Apache + Perl scripts
I'am new in Linux.
I install RedHat 6.0 and Apache 1.3.9
I have some HTML pages wich invoque Perl Scripts.
So I put in the cgi-bin directory the Perl Scripts and I try to make them work from Apache.
I couldn't....
I would like to know what do I have to change in the httpd.conf so I can execute perl scripts.
And also all that I have to know about this...
I need a good explanation, because I'am new with this.
Remember is Apache 1.3.9...
I've just try this:
If I execute the perl script without Apache: "./test.pl"
says it can't find test.pl
Inside the perl file I have #!/usr/bin/perl
If I execute like this: "perl test.pl" things work fine...
I install RedHat 6.0 and Apache 1.3.9
I have some HTML pages wich invoque Perl Scripts.
So I put in the cgi-bin directory the Perl Scripts and I try to make them work from Apache.
I couldn't....
I would like to know what do I have to change in the httpd.conf so I can execute perl scripts.
And also all that I have to know about this...
I need a good explanation, because I'am new with this.
Remember is Apache 1.3.9...
I've just try this:
If I execute the perl script without Apache: "./test.pl"
says it can't find test.pl
Inside the perl file I have #!/usr/bin/perl
If I execute like this: "perl test.pl" things work fine...
Oh yeah, the actual location of the cgi-bin directory will undoubtedly different for your system.
make test.pl executable, if it's not already
chmod 0755 test.pl
will probably do it.
check access.conf (probably in /etc/httpd/conf) and make sure there's an entry
<Directory /home/httpd/cgi-bin>
Options ExecCGI
</Directory>
and restart httpd.
chmod 0755 test.pl
will probably do it.
check access.conf (probably in /etc/httpd/conf) and make sure there's an entry
<Directory /home/httpd/cgi-bin>
Options ExecCGI
</Directory>
and restart httpd.
ASKER
I try the change syou suggest but I still kave the same problem.
I send you the error log of the APache
PD: Prueba.pl is executable but stills says it can-t find the path, I do this outside Apache.... (./Prueba.pl), the same messages appears in the Apache log (see below)
LOG
[error 2] No such file or directory: Exec of /home/Apache/cgi-bin/Prueb a.pl failed
[error client 10.0.65.75] Premature end of scripts headers: /home/Apache/cgi-bin/Prueb a.pl
I send you the error log of the APache
PD: Prueba.pl is executable but stills says it can-t find the path, I do this outside Apache.... (./Prueba.pl), the same messages appears in the Apache log (see below)
LOG
[error 2] No such file or directory: Exec of /home/Apache/cgi-bin/Prueb
[error client 10.0.65.75] Premature end of scripts headers: /home/Apache/cgi-bin/Prueb
Papma,
Where is you perl resides? try "which perl".
Normall it should resides in /usr/bin, but sometimes, /usr/local/bin
verify it. and adjust you script accordingly.
Where is you perl resides? try "which perl".
Normall it should resides in /usr/bin, but sometimes, /usr/local/bin
verify it. and adjust you script accordingly.
When you attempt the execution of the perl script via "./Prueba.pl" are you in the /home/Apache/cgi-bin directory? When it fails there (with Prueba.pl at least permissions of rwxr-xr-x) does it say that it can't find Prueba.pl or does it say "Preuba.pl: No such file or directory"? The latter would mean that it can't find /usr/bin/perl. Is there a /usr/bin/perl? Could it be in a different location? Try "which perl" to see where the executable is.
If perl isn't in /usr/bin, you can make a logical link from where it is to /usr/bin. For example it the perl executable is in /usr/local/bin you could do (as root):
ln -s /usr/local/bin/perl /usr/bin/perl
If perl isn't in /usr/bin, you can make a logical link from where it is to /usr/bin. For example it the perl executable is in /usr/local/bin you could do (as root):
ln -s /usr/local/bin/perl /usr/bin/perl
ASKER
The message is "Prueba.pl: No such file or directory"?
I follow all your suggestions.
Perl reside in /usr/bin, so I don't need to make a link.
Prueba.pl is executable...
It 's very strange....
Any other idea?
I follow all your suggestions.
Perl reside in /usr/bin, so I don't need to make a link.
Prueba.pl is executable...
It 's very strange....
Any other idea?
Post the output of
stat Prueba.pl
just to make sure you've really set this to be executable.
stat Prueba.pl
just to make sure you've really set this to be executable.
There's either something wrong with the magic token on the first line of Prueba.pl or there's something wrong with what /usr/bin/perl is.
If you do "which perl" what do you see?
Carefuly paste the following two lines into a file that's opened in a Linux editor. Make very sure that the first line of the file is the "#!" token and that there is no leading whitespace on that line.
#!/usr/bin/perl
print "Hello world\n";
Make the file executable, then try running it with "./some-file".
If you do "which perl" what do you see?
Carefuly paste the following two lines into a file that's opened in a Linux editor. Make very sure that the first line of the file is the "#!" token and that there is no leading whitespace on that line.
#!/usr/bin/perl
print "Hello world\n";
Make the file executable, then try running it with "./some-file".
make sure the perl module is loaded in httpd.conf there should be a line LoadModule perl_module /usr/lib/apache/libperl.so
also in it should also be mentioned in AddModule mod_perl.c
Aslo try adding
<Location /cgi-bin>
AddHandler perl-script .pl
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
if this doesn't work go to http://www.apache.org/docs and lookup documents regarding perl.
also in it should also be mentioned in AddModule mod_perl.c
Aslo try adding
<Location /cgi-bin>
AddHandler perl-script .pl
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
if this doesn't work go to http://www.apache.org/docs and lookup documents regarding perl.
No you don't need the perl module to be able to execute a perl script as a CGI. The perl script has to be able to be run as if it's a program and that's where his problem lies.
ASKER
jlevie:
I try your solution: make a test.pl, then chmod 0755 test.pl
the code of test.pl is:
#!/usr/bin/perl
print "Hello world\n";
Then ./Test.pl in the cgi-bin directory,and I have the same error
"Test.pl: No such file or directory"?
If I do perl test.pl works fine.
I belive Perl couldn't be the problem because "Perl filename" won't work.
So colud be a bash probem?
Any other ideas?
Thanks.
I try your solution: make a test.pl, then chmod 0755 test.pl
the code of test.pl is:
#!/usr/bin/perl
print "Hello world\n";
Then ./Test.pl in the cgi-bin directory,and I have the same error
"Test.pl: No such file or directory"?
If I do perl test.pl works fine.
I belive Perl couldn't be the problem because "Perl filename" won't work.
So colud be a bash probem?
Any other ideas?
Thanks.
ASKER
I will give the poinbts to jlevie which was "near" of the final answer.
The solution:
I edit the Perl file with Vi editor which add a <ctrl M> after the #!/usr/bin/perl
So if I edit the perl file with another editor I remove this character and all works fine.
Thanks all, for your comments.
Jlevie please lock the question.
The solution:
I edit the Perl file with Vi editor which add a <ctrl M> after the #!/usr/bin/perl
So if I edit the perl file with another editor I remove this character and all works fine.
Thanks all, for your comments.
Jlevie please lock the question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I import the file from Windows, then I add the line #!.... with the VI of Linux RedHat 6.0
Ah, that's why. I think in a case like that vi may be "respecting" the line terminators in the file. If you do the transfers with FTP, using "text" mode should cause the carriage returns to be stripped. And you want them to be gone as other Unix things are likely to be confused by their presence.
<Directory "/opt/Apache/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>