Solved

Red Hat/Apache Perl/CGI question

Posted on 2000-05-16
12
638 Views
Last Modified: 2013-11-18
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 ./scriptname.pl 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.


thanks

0
Comment
Question by:ttrogden
  • 6
  • 2
  • 2
  • +2
12 Comments
 
LVL 1

Expert Comment

by:bcoleman
Comment Utility
/etc/httpd/access.conf
0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
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
0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
this is what i have in the access.conf file


****************************

</Directory>

# /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
</Directory>


*************************



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


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



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


0
 
LVL 2

Expert Comment

by:linuxwrangler
Comment Utility
Check the file permissions (ls -l count.pl) and make sure that apache has read and execute permissions for that file and the cgi-bin directory. You can try "chmod 0755 count.pl" (give group and world read/execute permission) and see if it starts working.
0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
it had those permissions.  THis is getting frustrating.  Is there anymore information i can post to help with finding out what the problems is ?


0
 
LVL 1

Accepted Solution

by:
bcoleman earned 50 total points
Comment Utility
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:jyu_88
Comment Utility
CGI/SSI should be closely administered and screened for potential security risk. donot allow just anybody to put out their test.pl into a public-accessible web server.
0
 
LVL 2

Expert Comment

by:linuxwrangler
Comment Utility
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 count.pl 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 count.pl 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.
0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
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



*********Access.conf***********

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

<Directory />
Options None
AllowOverride None
</Directory>

# 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

</Directory>

# /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
</Directory>




************Httpd.conf********

# 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
</Directory>

<VirtualHost 207.218.228.230>
ServerName www.gaylenet.com
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
</directory>
Options ExecCGI FollowSymLinks Includes IncludesNOEXEC Indexes MultiViews SymLinksIfOwnerMatch
</VirtualHost>







0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
I'm pretty sure i don't have SSI turned on - where can i check to see if this is the case
0
 
LVL 17

Expert Comment

by:psimation
Comment Utility
ttrogden
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 cout.pl, 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 count.pl 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.
0
 
LVL 1

Author Comment

by:ttrogden
Comment Utility
Comment accepted as answer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now