[Lvlug] Letting users run CGI scripts

Faber J. Fedor faber at linuxnj.com
Tue Dec 5 15:00:42 EST 2006


I want to allow users to run their own Perl CGI scripts (I'm the only
user and there's no Internet access, so let's not worry about security).
I've set UserDir to public_html and the URL http://127.0.0.1/~faber
brings up my index.html page.

My massively complex CGI script hello.pl is as follows:

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

If I set a ScriptAlias like this:

ScriptAlias /bin/ "/home/faber/public_html/ranking_reports/"

and goto http://127.0.0.1/bin/hello.pl the script runs perfectly so I
know the permissions, handlers, mod_perl, etc. are properly set.

What I can't figure out how to do is to run CGI scripts outside of
ScriptAliases, e.g. from a user directory.  According to TFM at
http://httpd.apache.org/docs/2.0/howto/cgi.html all I need to do is

<Directory /home/faber/public_html/ranking_reports/>
    Options ExecCGI
</Directory>

If I do that, hello.pl is treated as a file and I see the contents of
hello.pl in my browser, so I add a handler:

<Directory /home/faber/public_html/ranking_reports/>
    AddHandler cgi-script .pl
    Options ExecCGI
</Directory>

And I get Error 500.  The error log simply says "Premature end of script
headers: hello.pl".

I've tried every variation I've come across (ExecCGI/+ExecCGI, pl/.pl).
I've made changes to the global Options and AddHandlers as well as local
ones.  I've restarted the browser. I've even changed the name of the
script to avoid caching issues. Same problem on FC3 and RHEL3 running
Apache 2.0.

I can't figure out what FM I need to do to run CGI scripts from a
user directory. Any ideas what to try next?

-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the Lvlug mailing list