LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-31-2012, 07:49 AM   #1
Tushir_Pruthi
LQ Newbie
 
Registered: Aug 2012
Posts: 7

Rep: Reputation: Disabled
CGI scripts are not working. Getting failed with Internal Server Error


Errors in error log are:

[Mon Dec 31 13:22:31 2012] [error] [client 57.219.108.65] (13)Permission denied: exec of '/var/www/cgi-bin/first.cgi' failed
[Mon Dec 31 13:22:31 2012] [error] [client 57.219.108.65] Premature end of script headers: first.cgi

Script is working fine when tried to execute manually using perl interpreter.

It has 755 permission as well.

SELinux is disabled.

Apache settings

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>


Below are version details:

[root@atl-mc-vjb002 logs]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

[root@atl-mc-vjb002 logs]# httpd -version
Server version: Apache/2.2.3
Server built: Feb 22 2012 10:54:44
[root@atl-mc-vjb002 logs]# perl -v

This is perl, v5.8.8 built for x86_64-linux-thread-multi


[root@atl-mc-vjb002 logs]# sestatus
SELinux status: disabled
I have tried disabling suexec as well but it also did not help.

Same cgi page is working fine on other server.
 
Old 12-31-2012, 10:59 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Script is working fine when tried to execute manually using perl interpreter.
What you mean by that?
You need to have the appropriate shebang in the 1st line of the script, e.g:
Code:
#!/usr/bin/perl
<-rest of cgi script->
Regards
 
Old 01-01-2013, 02:43 AM   #3
Tushir_Pruthi
LQ Newbie
 
Registered: Aug 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks for reply. I am using the below script for testing cgi which is getting failed.
I am already specifying the path for perl binary in the first line.

[root@atl-mc-vjb002 cgi-bin]# cat first.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, world!\n";
 
Old 01-01-2013, 02:45 AM   #4
Tushir_Pruthi
LQ Newbie
 
Registered: Aug 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
I am able to execute the script when i try to execute it manually.

[root@atl-mc-vjb002 cgi-bin]# cat first.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, world!\n";


Execution
[root@atl-mc-vjb002 cgi-bin]# perl first.cgi
Content-type: text/html

Hello, world!
 
Old 01-01-2013, 03:54 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Execution
[root@atl-mc-vjb002 cgi-bin]# perl first.cgi
Content-type: text/html

Hello, world!
Are you sure it's executable?
Code:
ls -l first.cgi
Can you run it without invoking perl?
Code:
./first.cgi
 
Old 01-01-2013, 05:31 AM   #6
Tushir_Pruthi
LQ Newbie
 
Registered: Aug 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Its permission is 755. Pasting the output below. But not able to execute as .first.cgi

[root@atl-mc-vjb002 cgi-bin]# ls -l first.cgi
-rwxr-xr-x 1 root root 78 Dec 31 11:25 first.cgi
[root@atl-mc-vjb002 cgi-bin]# ./first.cgi
-bash: ./first.cgi: /usr/bin/perl: bad interpreter: Permission denied
 
Old 01-01-2013, 05:44 AM   #7
Tushir_Pruthi
LQ Newbie
 
Registered: Aug 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks so much for helping me in identifying the problem.
Its working now.
/var partition was mounted with noexec option. I have corrected it.
Now cgi script is working fine.
 
  


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 not working on the httpd server Roboserg Linux - Server 14 12-06-2012 06:20 AM
500 Internal Server Error - CGI Script sp0oon Fedora 1 11-11-2012 11:06 AM
CGI Internal Server error linuxguy08 Linux - Server 2 03-30-2011 12:54 PM
CGI / Perl Internal Server Error newuser455 Linux - General 10 09-26-2004 02:50 AM
CGI Internal server error newuser455 Linux - General 2 06-10-2004 09:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:52 PM.

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