Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 14th, 2001, 04:13 AM
optimised optimised is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 10 optimised User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old September 14th, 2001, 07:14 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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)

Reply With Quote
  #3  
Old September 17th, 2001, 04:01 AM
optimised optimised is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 10 optimised User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>

Reply With Quote
  #4  
Old September 17th, 2001, 04:16 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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">

Reply With Quote
  #5  
Old September 17th, 2001, 07:13 PM
optimised optimised is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 10 optimised User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old September 17th, 2001, 08:07 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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.

Reply With Quote
  #7  
Old September 18th, 2001, 01:03 PM
optimised optimised is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 10 optimised User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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..

Reply With Quote
  #8  
Old September 19th, 2001, 08:45 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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.

Reply With Quote
  #9  
Old September 21st, 2001, 05:26 AM
optimised optimised is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 10 optimised User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
IT WORKS NOW.

Thanks for all your help.
Now that apache is configured properly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > CGI-SCRIPT Internal error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway