LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache 2.2: Execute CGI script from user directory (https://www.linuxquestions.org/questions/linux-server-73/apache-2-2-execute-cgi-script-from-user-directory-641830/)

jf.argentino 05-13-2008 04:01 AM

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?

bathory 05-14-2008 02:14 AM

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.

datopdog 05-14-2008 02:15 AM

You need this
Code:

ScriptAlias /cgi-bin/ "/home/*/html/cgi-bin/"

jf.argentino 05-14-2008 02:36 AM

Well, thanks but neither of your answer work! Any more ideas?

bathory 05-14-2008 02:52 AM

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.

jf.argentino 05-14-2008 03:07 AM

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.

bathory 05-14-2008 03:21 AM

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.


All times are GMT -5. The time now is 04:51 PM.