LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 07-27-2002, 10:21 AM   #1
CragStar
Senior Member
 
Registered: Oct 2000
Location: UK - Frome
Distribution: Ubuntu
Posts: 1,081

Rep: Reputation: 45
Apache Config for users to execute CGI scripts


Does anyone know how to configure the apache config file httpd.conf to allow users to execute CGI programs. What I would like is to basically allow any CGI script that is contained in any cgi-bin directory to be allowed to execute, under an address like so:

http://localhost/~com/cgi-bin/test.cgi

or

http://localhost/~com/cps/cgi-bin/test.cgi

What I don't want to do is individually set-up each directory to use CGI. If this is not possible then does anyone know how to configure the conf file to set up CGI in any directory?

Thanks
 
Old 07-27-2002, 10:20 PM   #2
kobe
Member
 
Registered: Jun 2002
Location: Australia
Distribution: RH 7.3 & Debian (Woody)
Posts: 30

Rep: Reputation: 15
getting cgi to work

my understanding (the way i got it working on my box!!) is that u have to have this in ur http.conf file

<Directory "/var/www/cgi-bin">
Options ExecCGI

AllowOverride None
Allow from from all


Order allow,deny
</Directory>

also try using "webmin" i find it not too bad for configuring apache, a bit complex and weird sometimes but handy!

hope this helps!!
 
Old 08-01-2002, 01:47 PM   #3
CragStar
Senior Member
 
Registered: Oct 2000
Location: UK - Frome
Distribution: Ubuntu
Posts: 1,081

Original Poster
Rep: Reputation: 45
So if I wanted to use any home directory I could use:

<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI

AllowOverride None
Allow from from all


Order allow,deny
</Directory>

I will try that out. The error I keep getting is to do with Premature end of script headers. I have checked the Apache docs, but none of the advice is particularly useful. I know that I cab run CGI perl scripts, because I am able to use the script alias thing, but I really need to run CGI in the home directorys.

Thanks anyways.
 
Old 08-01-2002, 03:06 PM   #4
naz
Member
 
Registered: Aug 2002
Location: Malaysia
Distribution: RedHat
Posts: 58

Rep: Reputation: 15
Premature end of script headers is usually a symptom of DOS formatted perl scripts. Use the command "dos2unix" to convert these into UNIX formatted perl scripts.

naz
 
Old 08-02-2002, 11:56 AM   #5
CragStar
Senior Member
 
Registered: Oct 2000
Location: UK - Frome
Distribution: Ubuntu
Posts: 1,081

Original Poster
Rep: Reputation: 45
I can't see how that is true seeing as the scripts can be excuted, and the fact they were written and saved in Linux. All they do is say Hello World in Perl.

I'm pretty sure that this is an apache config problem, or something to do with the user who runs apache, who in this case is webuser.
 
Old 12-08-2002, 05:56 PM   #6
huxtablejones
LQ Newbie
 
Registered: Dec 2002
Posts: 12

Rep: Reputation: 0
I have the exact same problem. Did you ever find a solution, or does anyone have a solution for this? The script I am using is a very simple one that I use to test cgi permissions - runs on all my other boxes. Permissions set to 755

RH8, perl 5.x, apache 2.x

edit -

christ, I posted this on the wrong thread....I am attempting to run this script from the default /var/www/cgi-bin/ folder, not a user home directory...sorry

/edit

Last edited by huxtablejones; 12-08-2002 at 05:58 PM.
 
Old 12-09-2002, 09:48 AM   #7
mhholloway
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake
Posts: 2

Rep: Reputation: 0
I'm not guaranteeing that this is your problem, but I found that suexec gave me fits similar to what you are describing. The easiest fix is to locate suexec, and move it to another directory, then restart apache. The reason is that (i think) suexec is compiled into the RPM with CGI running as the user has to be run from under the /var/www/cgi-bin directory. When you setup virtual servers that run from users home directories (i.e. /home/user/www/cgi-bin), seexec will not allow the script to run. You're supposed to be able to recompile suexec to use another directory, but I have never been brave enough to do it without specific directions from an advanced user. I do know that you can set Apache to run as user Apache and group Apache in the conf file, then remove suexec from the default path and Apache will run the scripts where you tell them to. I would just like to run Apache as the user instead of Apache.
Hope this helps somehow,
Mark
 
Old 01-18-2003, 05:03 PM   #8
Screech
LQ Newbie
 
Registered: Dec 2002
Posts: 4

Rep: Reputation: 0
This solved the same problems for me.

chmod -R 755 /var/www/cgi_bin
chgrp -R apache /var/www/cgi-bin
chown -R apache /var/www/cgi-bin

See also....
http://www.redhat.com/support/resou...he-FAQ/x33.html

Wam! No more Premature end of script headers errors.
 
Old 01-19-2003, 03:55 PM   #9
mhholloway
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake
Posts: 2

Rep: Reputation: 0
re: 755

The problem you will find (that I previously encountered) is that when files are created by apache through the cgi, they will be owned by apache. If the user logs in via ftp, telnet, or ssh, they will not have the permissions needed to edit or delete them. By fixing suexec, apache will run as the user, and all files or directories created by cgi processes will be owned by that user. In some situations, the 755 and group change will work fine, in others, it won't.
 
Old 01-20-2003, 01:37 AM   #10
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,457

Rep: Reputation: 104Reputation: 104
i had to delete my post. it is too early...sorry
cheers, jens

Last edited by j-ray; 01-20-2003 at 02:02 AM.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache CGI config question (index scripts) rjlee Linux - Networking 1 06-26-2005 07:07 AM
how to execute shell scripts from cgi script rajatgarg Linux - General 1 07-08-2004 02:39 PM
Failed to execute cgi script in Apache!! baby_linu Linux - Newbie 4 06-30-2004 05:23 PM
Apache cgi scripts! boyinfrance Linux - Newbie 2 06-22-2002 11:33 PM
Can't execute *.cgi scripts. BrianG Linux - General 1 04-11-2001 04:38 AM


All times are GMT -5. The time now is 08:14 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration