|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
CGI-SCRIPT Internal error
I am trying to get my web server to execute cgi-scripts. I'm starting off using this small script listed below. I put the script in the /var/www/cgi-bin directory and in my domain's cgi-bin folder.
> /home/mydomain/www/cgi-bin (I have chmod 755 both places.) #!/usr/bin/perl # print "Content-type: text/html\n\n"; print "Hello World\n"; I ran >perl -c test.cgi syntax fine Then >perl - w test.cgi Hello World command line works fine returns- Hello World. /cgi-bin>#perl test.cgi But running http://mydomain/cgi-bin/test.cgi I keep getting internal error 505 Error_log [error] (2) No such file or directory: exec of /home/mydomain/www/cgi-bin/test.cgi [error] Premature end of script headers ## httpd.conf - configuration for the Apache web server #enable cgi-scripts ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> #use cgi-scripts AddHandler cgi-script .cgi .pl # If the perl module is installed, this will be enabled. <IfModule mod_perl.c> Alias /perl/ /var/www/perl/ <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options None </Location> </IfModule> ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/" <Directory "/home/mydomain/www/cgi-bin"> Options None AllowOverride None Order allow,deny Allow from all </Directory> # Virtual host mydomain <VirtualHost x.x.x.x> DocumentRoot /home/mydomain/www ServerName www.mydomain.com ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/" ServerSignature email </VirtualHost> Thanks Last edited by optimised : September 17th, 2001 at 03:44 AM. |
|
#2
|
|||
|
|||
|
>> ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/"
Uncomment this line. You already defined that in <VirtualHost> block. >> Allow from from all Remove the duplicated from >> DocumentRoot /home/mydomain/www/ Remove the trailing slash >> Why can't it find file in /home/mydomain/www/cgi-bin The error (2) No such file or directory was actually a little misleading. >> [error] (2) No such file or directory: exec of... Two possible causes: 1) The real path to Perl #!/usr/bin/perl was incorrect 2) There was a trailing ^M at the end of line of every line (including the 1st line like so: #!/usr/bin/perl^M That's all about Error no. 2. Just make sure *.pl extension is uploaded in ASCII mode. Just so you know, here is what Error no.8 is all about: One possible cause: - The first line is not the line to your interpreter (perhaps a blank line on the 1st line) |
|
#3
|
|||
|
|||
|
Hello,
I made corrections and verified perl to path, checked for ^M Everything seems to be correct. Still no success. Is there any reason I can't run cgi-scripts from a directory such as /home/mydomain/www/cgi-bin ? Directory and script are 0755 ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/" <Directory "/home/mydomain/www/cgi-bin"> Options None AllowOverride None Order allow,deny Allow from all </Directory> Should I remove this part from httpd file?? maybe ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> |
|
#4
|
|||
|
|||
|
>> I made corrections and verified perl to path, checked for ^M
For Error No.2, as I said, two possible causes, nothing is related to permission, whatsoever. After re-reading your previous post, I've found some other misconfiguration. Though, they still have nothing to do with Error no.2. >> # Virtual host mydomain >> <VirtualHost x.x.x.x> >> DocumentRoot /home/mydomain/www >> ServerName www.mydomain.com >> ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/" You Alias or ScriptAlias something only if it's not under your docroot. Your cgi-bin is a subdir under /home/mydomain/www/, so it violates Alias rule in Apache. >> Should I remove this part from httpd file?? maybe No. But you definitely need to remove the 2nd ScriptAlias line (you can't define multiple ScriptAlias lines globally), but you are allowed to define a ScriptAlias line within <VirtualHost>. That's why I told you previously to Uncomment this line. You already defined that in <VirtualHost> block. Anyhow, here is the lines you should alter to: #ScriptAlias /cgi-bin/ "/home/mydomain/www/cgi-bin/" <Directory "/home/mydomain/cgi-bin"> Options None AllowOverride None Order allow,deny Allow from all </Directory> # Virtual host mydomain <VirtualHost x.x.x.x> DocumentRoot /home/mydomain/www ServerName www.mydomain.com ScriptAlias /cgi-bin/ "/home/mydomain/cgi-bin/" ServerSignature email </VirtualHost> As you can see from the lines in bold, I have changed the location of your cgi-bin to /home/mydomain/cgi-bin. Keep in mind, you also need to define a directory block of <Directory "/home/mydomain/www"> |
|
#5
|
|||
|
|||
|
Same darn error
>running http://mydomain/cgi-bin/test.cgi >I keep getting internal error 505 >Error_log >[error] (2) No such file or directory: exec of /home/mydomain/www/cgi-bin/test.cgi >[error] Premature end of script headers Seems like apache can't see directory(s) Due to the fact that script runs from command line. |
|
#6
|
|||
|
|||
|
>> exec of /home/mydomain/www/cgi-bin/test.cgi
I already told you that violates ScriptAlias rule. Your cgi-bin can't reside under your docroot if it's scriptalias'ed. |
|
#7
|
|||
|
|||
|
Hi freebsd,
//www.mydomain.com/cgi-bin/test.cgi Sorry error is /home/mydomain/cgi-bin/test.cgi [error] (2) No such file or directory: exec of /home/mydomain/cgi-bin/test.cgi [error] Premature end of script headers I have changed location of cgi-bin to /home/mydomain/cgi-bin I have incorporated changes you suggested above> ScriptAlias /cgi-bin/ "/home/mydomain/cgi-bin/" <Directory "/home/mydomain/www"> Options None AllowOverride None Order allow,deny Allow from all </Directory> <Directory "/home/mydomain/cgi-bin"> Options None AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost x.x.x.x> DocumentRoot /home/mydomain/www ServerName www.mydomain.com ScriptAlias /cgi-bin/ "/home/mydomain/cgi-bin/" ServerSignature email </VirtualHost> So my cgi-bin is not under docroot of www? It resides as /home/mydomain/cgi-bin Thks for help.. |
|
#8
|
|||
|
|||
|
>> I have incorporated changes you suggested above>
Now they look fine. >> [error] (2) No such file or directory: exec Again, two possible causes. The ^M is not human-visible unless you run vi /home/mydomain/cgi-bin/test.cgi. That said, you can't see it if you do cat /home/mydomain/cgi-bin/test.cgi. Anyhow, you can try here and run your test.cgi thru it. |
|
#9
|
|||
|
|||
|
IT WORKS NOW.
Thanks for all your help. Now that apache is configured properly. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > CGI-SCRIPT Internal error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|