LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2006, 08:00 AM   #1
DLHOMME
LQ Newbie
 
Registered: Dec 2005
Location: Lévis, Qc, Canada
Distribution: Suse 10.2
Posts: 26

Rep: Reputation: 15
CGI scripts - Persistent Server 500 errors


I am using Suse Linux 10.0 and installed the default setup of Apache(2.0.54):
-/srv/www/cgi-bin
- ScriptAlias=/cgi-bin/ "/srv/www/cgi-bin/"

I placed the following minimal script in the /srv/www/cgi-bin directory:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello world.";

I did the chmod a+x on the script file which now has the following properties:

-rwxrwxrwx 1 root root 74 2006-05-18 16:36 first.pl

From the command line, I call /srv/www/cgi-bin/first.pl and I get:
Content-type: text/html

Hello world.
So there does not seem to be anything wrong with the script.
Yet, the browser gives me:

"Server error!
The server encountered an internal error and was unable to complete your request.
Error message:

Premature end of script headers: first.pl
If you think this is a server error, please contact the webmaster.
Error 500"

The system log gives me:
"May 19 08:54:33 HPa730n kernel: SubDomain: REJECTING x access to /srv/www/cgi-bin/cgi (httpd2-prefork(9971) profile /usr/sbin/httpd2-prefork active /usr/sbin/httpd2-prefork)"

Can anybody tell me what I'm missing?
Thank you.
 
Old 05-19-2006, 10:51 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Have you checked everything from:
http://httpd.apache.org/docs/2.2/howto/cgi.html
especially from the troubleshooting section?

Have you also tried chown'ing them? Apache may not want to execute
programs with rwxrwxrwx permissions, owned by root user and group.

Last edited by timmeke; 05-19-2006 at 10:54 AM.
 
Old 05-19-2006, 11:13 AM   #3
DLHOMME
LQ Newbie
 
Registered: Dec 2005
Location: Lévis, Qc, Canada
Distribution: Suse 10.2
Posts: 26

Original Poster
Rep: Reputation: 15
Thank you for the suggestions.
Yes,I have checked everything in the link.
I have also chown'd the file to user -denis (that's me) and to group -users.
Same problem. UIt is an access problem all right as withnessed by the Apache2 error log file.
"[Fri May 19 12:06:00 2006] [error] [client 192.168.0.9] (13)Permission denied: exec of '/srv/www/cgi-bin/first2.pl' failed
[Fri May 19 12:06:00 2006] [error] [client 192.168.0.9] Premature end of script headers: first2.pl"
 
Old 05-22-2006, 02:23 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Can you list the directory permissions of all following directories:
/srv
/srv/www
/srv/www/cgi-bin/

Maybe executing fails because the user Apache is running under doesn't have permission to reach the file.
 
Old 05-22-2006, 10:42 AM   #5
DLHOMME
LQ Newbie
 
Registered: Dec 2005
Location: Lévis, Qc, Canada
Distribution: Suse 10.2
Posts: 26

Original Poster
Rep: Reputation: 15
Here is the result of ls -l on the /srv/www/cgi-bin directory:

HPa730n:/srv/www/cgi-bin # ls -l
total 228
drwxrwxrwx 2 denis users 432 2006-05-19 12:43 .
drwxrwxrwx 7 denis users 168 2006-05-09 08:21 ..
-rwxrwxrwx 1 denis users 1147 2006-05-19 12:43 cgi
-rwxrwxrwx 1 denis users 1149 2006-05-19 12:43 cgi~
-rwxrwxrwx 1 denis users 1147 2006-05-10 10:59 cgi1
-rwxrwxrwx 1 denis users 104 2006-05-10 08:35 check
-rwxrwxrwx 1 denis users 104 2006-05-10 08:35 check~
-rwxrwxrwx 1 denis users 75 2006-05-19 09:57 first1.pl
-rwxrwxrwx 1 denis users 75 2006-05-19 12:03 first2.pl
-rwxrwxrwx 1 denis users 74 2006-05-18 16:36 first.pl
-rwxrwxrwx 1 denis users 110 2006-05-10 16:27 first.pl~
-rwxrwxrwx 1 denis users 111884 2005-09-09 15:05 htsearch
-rwxrwxrwx 1 denis users 24679 2005-09-09 14:59 info2html
-rw-rw-rw- 1 denis users 1780 2005-09-09 14:59 info2html.conf
-rwxrwxrwx 1 denis users 43764 2005-09-09 15:05 qtest
-rw-rw-rw- 1 denis users 1326 2006-05-10 10:29 test.html
 
Old 05-22-2006, 12:46 PM   #6
iuaui
Member
 
Registered: Sep 2005
Location: Nummela, Southern Finland
Distribution: Fedora Core 4, Fedora Core 5, Redhat 9.0, Solaris 10, WInXP pro, W2k pro
Posts: 30

Rep: Reputation: 15
No no, what the other bloke ment was give the output of
ls -la /srv
ls -la /srv/www and
ls -la /srv/www/cgi-bin
Well the last one is shown in your reply but these other two should have permissions to execute by "anyone"...
 
Old 05-22-2006, 01:21 PM   #7
DLHOMME
LQ Newbie
 
Registered: Dec 2005
Location: Lévis, Qc, Canada
Distribution: Suse 10.2
Posts: 26

Original Poster
Rep: Reputation: 15
I had checked that too.
But just to show you I'm not lying, here it is:
HPa730n:/srv # ls -l
total 1
drwxrwxrwx 4 denis users 96 2005-09-09 12:27 .
drwxr-xr-x 23 root root 544 2006-05-18 13:01 ..
drwxr-xr-x 2 root root 48 2005-09-09 12:27 ftp
drwxrwxrwx 7 denis users 168 2006-05-09 08:21 www
HPa730n:/srv # cd www
HPa730n:/srv/www # ls -l
total 1
drwxrwxrwx 7 denis users 168 2006-05-09 08:21 .
drwxrwxrwx 4 denis users 96 2005-09-09 12:27 ..
drwxrwxrwx 2 denis users 432 2006-05-19 12:43 cgi-bin
drwxrwxrwx 4 denis users 128 2005-11-10 08:37 htdig
drwxrwxrwx 3 denis users 1408 2006-05-10 08:58 htdocs
drwxrwxrwx 2 denis users 144 2005-11-10 08:42 icons
drwxrwxrwx 2 denis users 48 2005-09-09 14:55 perl-lib
 
Old 05-22-2006, 01:44 PM   #8
iuaui
Member
 
Registered: Sep 2005
Location: Nummela, Southern Finland
Distribution: Fedora Core 4, Fedora Core 5, Redhat 9.0, Solaris 10, WInXP pro, W2k pro
Posts: 30

Rep: Reputation: 15
Ok. How is your Directory directive for alias cgi-bin?
Is it something like this?
Code:
<Directory "/srv/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
And have you restarted your server lately?
 
Old 05-22-2006, 02:23 PM   #9
DLHOMME
LQ Newbie
 
Registered: Dec 2005
Location: Lévis, Qc, Canada
Distribution: Suse 10.2
Posts: 26

Original Poster
Rep: Reputation: 15
<Directory "/srv/www/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
 
Old 05-22-2006, 02:56 PM   #10
iuaui
Member
 
Registered: Sep 2005
Location: Nummela, Southern Finland
Distribution: Fedora Core 4, Fedora Core 5, Redhat 9.0, Solaris 10, WInXP pro, W2k pro
Posts: 30

Rep: Reputation: 15
Ok, now I think I know what is the issue here. You should not use Options +ExecCGI unless you have cgi-bin -directory outside the cgi-bin ScriptAlias. So if you have
Code:
ScriptAlias cgi-bin "/what/ever/cgi-bin/"
in your MainServer directive, you could try using
Code:
Options none
in your cgi-bin Directory directive.
To put it alltogether chance your config to
Code:
<Directory "/srv/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
save your configuration, restart server and laugh to me, if it doesn't work.

Last edited by iuaui; 05-22-2006 at 03:02 PM.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI scripts - Persistent Server 500 errors DLHOMME Linux - Networking 1 05-19-2006 07:56 AM
Apache Web Server and CGI scripts jonty_11 Red Hat 2 05-17-2006 01:52 PM
Perl-CGI 500 Error tzarcone Programming 1 07-01-2005 02:45 AM
RH 8.0 CGI 500 error (apache) 3Dxx Linux - General 46 06-27-2005 05:51 AM
HELP! CGI problem : HTTP 500 - Internal server error eech55 Programming 2 10-11-2004 11:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration