LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-12-2005, 05:10 PM   #1
DaveVT5
LQ Newbie
 
Registered: Dec 2005
Location: Blacksburg, VA
Distribution: Fedora Core 4
Posts: 12

Rep: Reputation: 0
Exclamation Apache CGI problem in Fedora Core 4


Overview

I am having an incredible amount of difficulties getting cgi scripts to run. I am running Apache 2.0.54 on Fedora Core 4. I have already disabled SElinux. I am getting an "internal server error" error. I have succeeded in installing and configuring PHP, MySQL, phpMyAdmin, MediaWiki and phpBB2 (notice that they all use PHP and not CGI?) For the life of my I have been unable to get any perl scripts to work.


Background

I have created a user intranet who's home directory is: /home/intranet/. I have created a sub directory called www and uploaded a cgi file named test.cgi

The contents of the /home/intranet/www/test.cgi are as follows:
Code:
#!/usr/bin/perl
##################################
##################################
###                            ###
###   CGI IS NOT INSTALLED    ###
###                            ###
###  (or .cgi assoc. not set)  ###
###                            ###
##################################
##################################

print "Content-type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test File</title>";
print "</head>";
print "<body><font face=arial>Perl is installed on your server";
print "<br/>(and the .cgi extension is associated)</font>";
print "</body></html>";
I have run chmod 755 test.cgi from the command line.

I have configured Apache as follows:
Code:
<VirtualHost 10.20.30.5:80>
     ServerName intranet.modea.com
     ServerAlias *.intranet.modea.com
     AddHandler cgi-script .cgi
     DocumentRoot /home/intranet/www
     DirectoryIndex index.html index.htm
     ServerSignature email
     SuexecUserGroup intranet intranet

     <Directory />
         Options ExecCGI
         AddHandler cgi-script .cgi
         AllowOverride None
         Allow from all
         Order allow,deny
     </Directory>
</VirtualHost>
Some of the above code is superfluous, however it should not conflict.

When I access the file over the web I get a standard "500 Internal Server Error" message.

The /var/httpd/error_log file shows the following:
Quote:
[Mon Dec 12 17:09:25 2005] [error] [client 10.20.30.109] Premature end of script headers: test.cgi
The /var/httpd/suexec.log show this:
Quote:
[2005-12-12 17:17:06]: uid: (501/intranet) gid: (501/501) cmd: t.cgi
[2005-12-12 17:17:06]: command not in docroot (/home/intranet/www/t.cgi)
(I'm not really sure what this log file is/says)


Other stuff

Here is the contents of my /home/intranet/www/ directory:
Quote:
-rw-r--r-- intranet intranet index.html
-rwxrwxrwx intranet intranet t.cgi
-rwxrwxrwx intranet intranet test.cgi
You will see that I actually chmod 777 the test.cgi files. The files were originally owned by root because I created them at the command line while logged in as root. To change the user and group I ran the following while in /home/intranet/:
Code:
chown -R intranet.intranet www
(I received an Internal Server Error message regardless of the file ownership)


My Thoughts

Even after significant research and "tweaking" I have been unsuccessful at getting this to work. I have seen many other people have issues running CGI using Fedora. Most of it seems to revolve around SElinux, which I disabled (by editing /etc/selinux/config and setting "SELINUX=disabled" then rebooting)

I can serve up static .html pages without incident. I think I have everything configured correctly but obviously I do not. I've been looking at this for so long that I cannot see the forest through the trees so any help would be appreciated.

Last edited by DaveVT5; 12-12-2005 at 05:30 PM.
 
Old 12-13-2005, 10:46 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,905

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
I think that your problem is suexec (I have never used it so I don't know how exactly it works)
Test your config with:
Code:
apachectl -t
Try to edit <VirtualHost> to see if it works:
Code:
<VirtualHost 10.20.30.5:80>
     ServerName intranet.modea.com
     ServerAlias *.intranet.modea.com
     AddHandler cgi-script .cgi
     DocumentRoot /home/intranet/www
    Options +ExecCGI
     AddHandler cgi-script .cgi
</VirtualHost>

Last edited by bathory; 12-13-2005 at 10:47 AM.
 
Old 12-13-2005, 11:06 AM   #3
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHL9;F1-10; CentOS4-5; DebianSarge-Squeeze
Posts: 1,151

Rep: Reputation: 46
The first time I tried to use cgi scripts in apache outside of /var/www/cgi-bin, I thought I was going to pull my hair out before getting it to work, so hang in there.

There are a few differences between your httpd.conf and mine, which may or may not have anything to do with your problems.

1) Try naming the directory explicitly in the “Options ExecCGI” directory section:

<Directory “/home/intranet/www”>
Options ExecCGI
AllowOverride None
Allow from all
Order allow,deny
</Directory>

2) “AddHandler cgi-script .cgi” only appears in my virtual host definition, not in the “Options ExecCGI” directory section. I doubt that is the problem.

3) “SuexecUserGroup” wasn’t used in my virtual host definitions. By following the script execution in top, you can see that the user “apache” is executing the script, which agrees with everything I have read about apache. So the implicit definition of the user and group must be “apache” (i.e., SuexecUserGroup apache apache),

4) In my implementation of “Options ExecCGI”, it is defined outside of the virtual host definition, just like how the standard /var/www/cgi-bin “Options ExecCGI” is defined, probably at the end of your httpd.conf.

5) My scripts will run with root as owner/group or with a non-root owner/group. The *.cgi files have permission 755.

Again, none of these differences may be relevant to your problem.
 
Old 01-04-2006, 09:33 AM   #4
DaveVT5
LQ Newbie
 
Registered: Dec 2005
Location: Blacksburg, VA
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
What I ended up doing was removing the suexec from the configuration. So now all scripts are run as apache:apache. I still need to figure out how to get scripts to run as the individuel user for security reasons but for now this will do.

Thank you all for your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
apache problem in fedora core 3 BloodyCat Linux - Software 1 09-20-2005 02:00 PM
Apache cgi-script problem palanisaravanan Linux - General 6 02-07-2004 09:41 AM
Apache CGI Problem : Browser not running script Zaknafien Linux - Software 3 12-31-2003 01:16 PM
apache v2.0.44 + cgi ; securing cgi-support in apache markus1982 Linux - General 0 01-20-2003 01:03 PM
apache cgi problem nyroc Linux - Software 2 11-29-2002 11:09 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration