LinuxQuestions.org
Review your favorite Linux distribution.
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 05-13-2008, 04:01 AM   #1
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 492

Rep: Reputation: 50
Apache 2.2: Execute CGI script from user directory


Hi all,

I try to execute a CGI script in a user directory, but all my browser is displaying is the source code! The same script works when called from the main cgi scripts location. After searching in the apache documentation, I think it's a user configuration problem but I can't fix it.

Here's the revelant (I think)parts of my httpd.conf :
Code:
...
LoadModule userdir_module modules/mod_userdir.so
...
DocumentRoot "/var/www"

<Directory />
    Options FollowSymLinks ExecCGI
    AllowOverride None
</Directory>

<Directory "/var/www">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_userdir.c
   UserDir html
</IfModule>

<Directory /home/*/html>
    AllowOverride Options
    Options Indexes FollowSymLinks ExecCGI
</Directory>

<Directory /home/*/html/cgi-bin>
    AllowOverride Options
    Options ExecCGI
    SetHandler cgi-scripts
    Order allow,deny
    Allow from all
</Directory>
...
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin/">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>
...
In my home i have the directory tree "/home/jf.argentino/html" and "/home/jf.argentino/html/cgi-bin", both are "755", and I can browse the "/home/jf.argentino/html/index.html" file...

What do I miss?
 
Old 05-14-2008, 02:14 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,885

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Change the following part of your config:
Quote:
<Directory /home/*/html/cgi-bin>
AllowOverride Options
Options ExecCGI
SetHandler cgi-scripts
Order allow,deny
Allow from all
</Directory>
to
Code:
<Directory /home/*/html/cgi-bin>
    AllowOverride Options
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl
    Order allow,deny
    Allow from all
</Directory>
and see if it works.
 
Old 05-14-2008, 02:15 AM   #3
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
You need this
Code:
ScriptAlias /cgi-bin/ "/home/*/html/cgi-bin/"

Last edited by datopdog; 05-14-2008 at 02:17 AM.
 
Old 05-14-2008, 02:36 AM   #4
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 492

Original Poster
Rep: Reputation: 50
Well, thanks but neither of your answer work! Any more ideas?
 
Old 05-14-2008, 02:52 AM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,885

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
What is the filename extension of the cgi script you're trying to run? If it's not .cgi or .pl, you should add it in the "AddHandler ..." directive.
 
Old 05-14-2008, 03:07 AM   #6
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 492

Original Poster
Rep: Reputation: 50
To Bathory: my scripts are .cgi ended.

To Datopdog: If I SciptAlias "/cgi-bin/" to "/home/*/html/cgi-bin/" I can't run script from the main cgi location (/var/www/cgi-bin/), I have seen on boot up messages that there's a ScriptAlias overlap problem, but I can't found it in any httpd/log files! Can I have only one SrciptAlias directive?

To all: I add a change "<Directory /home/*/html/cgi-bin>" into "<Directory /home/*/html/cgi-bin/>" without more success.

After some google'ing, I found that It could be caused by SELinux, but as far as I know SELinux isn't loaded on my box, I'll look on that way.
 
Old 05-14-2008, 03:21 AM   #7
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,885

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Quote:
To Bathory: my scripts are .cgi ended.
Since apache shows you the code and does not run the script, then it does not read the "AddHandler .." directive. I don't think it's a SELinux problem, because you should get a "Forbidden" or "Not found" error.
Check again the config file and also make sure that you don't have a .htaccess file in ~/ or ~/cgi-bin, that overwrites the httpd.conf settings.
 
  


Reply

Tags
apache, cgi, userdir


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
run cgi script as a user other than apache paul_mat Linux - Software 1 06-02-2006 02:01 PM
Execute a windows command from inside a c-cgi-script leamassiot General 51 02-09-2006 10:06 AM
how to execute shell scripts from cgi script rajatgarg Linux - General 1 07-08-2004 01:39 PM
Failed to execute cgi script in Apache!! baby_linu Linux - Newbie 4 06-30-2004 04:23 PM
Apache Config for users to execute CGI scripts CragStar Linux - General 9 01-20-2003 12:37 AM


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

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