LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Running web based perl scripts in userdirs (https://www.linuxquestions.org/questions/linux-networking-3/running-web-based-perl-scripts-in-userdirs-266359/)

markham82 12-14-2004 01:32 PM

Running web based perl scripts in userdirs
 
I'm running an apache web server (version 2.0.49) on a Fedore Core 2 machine. I'm have a few users using it with a UserDir on (e.g. I can do http://www.example.com/~user). I want to enable perl execution in the user's www directory. In each user's www directory is a cgi-bin directory. So I want users to run perl programs, like http://www.example.com/~user/cgi-bin/test.pl. I've been testing this with test.pl (see below). When I run it from the server root cgi-bin directory, e.g., http://www.example.com/cgi-bin/test.pl, it works totally fine. But when I test it in a user's directory, it fails. The error I get in the apache log is:

Code:

[Tue Dec 14 11:50:54 2004] [error] [client 192.168.1.104] Premature end of script headers: test.pl
I don't understand why it works under the document root and not under the user directories. Here is a portion of my httpd.conf file that I thought I configured correctly:

Code:

<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    #UserDir "disable"

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, use this directive instead of "UserDir disable":
    #
    UserDir www
</IfModule>

...

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

        SetHandler cgi-script

</Directory>

<Directory "/path/to/doc/root/testuser/www/cgi-bin">
        Options ExecCGI

        AllowOverride None
        Allow from from all

        Order allow,deny

</Directory>

This is the test perl program i'm trying to run:

Code:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";

Right now the home directories are in a place that is not under the document root. I tried creating a test user who's home directory was in fact under the document root, and created a www and a cgi-bin folder inside that. When I go to it on the web without UserDir it works, with UserDir, it doesn't. In other words:

http://www.example.com/testuser/www/cgi-bin/test.pl works,

http://www.example.com/~testuser/cgi-bin/test.pl does NOT work.

Permissions are all fine, the appropriate user owns all the directories involved. And the same perl program can be executed on the command line. Apache is being run as user: apache, group: apache.

Anyone have any ideas why this is happening and how it can be fixed? I would appreciate any help on this, thanks!

~Steve

peter_robb 12-15-2004 06:51 AM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

Original thread is http://www.linuxquestions.org/questi...hreadid=266351


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