Red Hat/Apache Perl/CGI question

I have a perl script I'm trying to run on an apache webserver.  I've pointed the script to the proper perl location and i can run the script in the folder with the ./ but when i try and call it from a webpage nothing happens.  I'm sure it has to do with SSI maybe not turned on the correct way.  I really didn't want to have to ask people to create a cgi-bin directory - i want to give them the rights to store there Perl/CGI programs in where in there webpage folder.  Do i need to modify something in the apache web conf files to allow them to do this.  if so - can some one point me to where i need to make these changes.


Who is Participating?
This is taken from apache documentation.

F. Dynamic Content (CGI and SSI)
How do I enable CGI execution in directories other than the ScriptAlias?
Apache recognizes all files in a directory named as a ScriptAlias as being eligible for execution rather than processing as normal documents. This applies regardless of the file name, so scripts in a ScriptAlias directory don't need to be named "*.cgi" or "*.pl" or whatever. In other words, all files in a ScriptAlias directory are scripts, as far as Apache is concerned.

To persuade Apache to execute scripts in other locations, such as in directories where normal documents may also live, you must tell it how to recognize them - and also that it's okay to execute them. For this, you need to use something like the AddHandler directive.

In an appropriate section of your server configuration files, add a line such as

AddHandler cgi-script .cgi

The server will then recognize that all files in that location (and its logical descendants) that end in ".cgi" are script files, not documents.

Make sure that the directory location is covered by an Options declaration that includes the ExecCGI option.

In some situations, you might not want to actually allow all files named "*.cgi" to be executable. Perhaps all you want is to enable a particular file in a normal directory to be executable. This can be alternatively accomplished via mod_rewrite and the following steps:

Locally add to the corresponding .htaccess file a ruleset similar to this one:

RewriteEngine on
RewriteBase /~foo/bar/
RewriteRule ^quux\.cgi$ - [T=application/x-httpd-cgi]

Make sure that the directory location is covered by an Options declaration that includes the ExecCGI and FollowSymLinks option.
ttrogdenAuthor Commented:
what do i need to add in this to allow each user to have there own CGI bin ??  I only saw a place for one folder like that
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

ttrogdenAuthor Commented:
this is what i have in the access.conf file



# /home/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

<Directory /home/gaylenet/public_html/cgi-bin>
AllowOverride None
Options ExecCGI


Here is the command I'm using in the web page

<!--#exec cmd="/home/gaylenet/public_html/cgi-bin/"-->

am i doing anything wrong - I can run the .pl file from the cgi-bin with a ./ and it works fine - the problem is when i try and call that from the web page.

Check the file permissions (ls -l and make sure that apache has read and execute permissions for that file and the cgi-bin directory. You can try "chmod 0755" (give group and world read/execute permission) and see if it starts working.
ttrogdenAuthor Commented:
it had those permissions.  THis is getting frustrating.  Is there anymore information i can post to help with finding out what the problems is ?

CGI/SSI should be closely administered and screened for potential security risk. donot allow just anybody to put out their into a public-accessible web server.
Divide and conquer: to determine what is not working try making a test script that creates a file. If the file gets created when you go via apache then the program is running OK so start looking elsewhere. I assume that already updates a file so check to see if the update is occurring. Also, be sure that the file being updated is set to the correct permissions to allow it to be written to.

Also make sure that the script returns the headers that are correct for the situation at hand and that there is an empty line between the http header and the file.
ttrogdenAuthor Commented:
ok - the pl script i have works - when i run it from the command line and it updates the count folder - i'm posting this as an FYI


# First, we configure the "default" to be a very restrictive set of
# permissions.

<Directory />
Options None
AllowOverride None

# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.

# This should be changed to whatever you set DocumentRoot to.

<Directory /home/httpd/html>

# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".

# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.

Options Indexes Includes FollowSymLinks

# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"

AllowOverride None

# Controls who can get stuff from this server.

order allow,deny
allow from all


# /home/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

<Directory /home/httpd/cgi-bin>
AllowOverride None
Options ExecCGI


# UseCanonicalName:  (new for 1.3)  With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a url that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a "canonical" name.  With this setting off, Apache will
# use the hostname:port that the client supplied, when possible.  This
# also affects SERVER_NAME and SERVER_PORT in CGIs.
UseCanonicalName on

<Directory > 
        Options ExecCgi Includes MultiViews Indexes FollowSymlinks SymLinksIfOwnerMatch
        AllowOverride AuthConfig FileInfo Indexes Limit Options

DocumentRoot /home/gaylenet/public_html
UserDir public_html
ScriptAlias /home/httpd/cgi-bin /home/gaylenet/public_html/
<directory "/home/gaylenet/public_html/cgi-bin/">
AllowOverride AuthConfig FileInfo Indexes Limit
Options ExecCGI Includes IncludesNOEXEC
Options ExecCGI FollowSymLinks Includes IncludesNOEXEC Indexes MultiViews SymLinksIfOwnerMatch

ttrogdenAuthor Commented:
I'm pretty sure i don't have SSI turned on - where can i check to see if this is the case
I believe we have the same problem. I can't get my script to execute either. I don't know if it is just by chance, but I am also battling with a, I bet it's the same script...
Anyway, I did exactly the same as you, and my script also executes perfectly if run from the command line. This in itself should point towards a server configuration error, but what I can't understand is the following. I have anothe perl script running from the same web page, that works perfect! The script is called from a submit button (perlfect search)--search engine. The script came with it's own installer, so unfortunately I can't see exactly what it does to make that script execute from the page. Whatever it does, doesn't seem to be a "global" perl/script fix, for the other script still won't execute...
I am in the process of slowly trying to decipher what the installer does, in the hope that I can do the same for the script.
You shouldn't waste more points on asking questions in other areas, I've already tried, each time I get the same response, check permissions, check httpd.conf, and like you too, access.conf, all without proper instructions. The answer in the end seems to fix the problem yourself. So, as soon as I've stumbled accross something, you'll be the first to know.
Hang in there.
ttrogdenAuthor Commented:
Comment accepted as answer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.