Solved

Red Hat/Apache Perl/CGI question

Posted on 2000-05-16
12
646 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +2
12 Comments
 
LVL 1

Expert Comment

by:bcoleman
ID: 2815626
/etc/httpd/access.conf
0
 
LVL 1

Author Comment

by:ttrogden
ID: 2815738
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
ID: 2815765
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:linuxwrangler
ID: 2815910
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
ID: 2817273
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
ID: 2818039
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
 
LVL 3

Expert Comment

by:jyu_88
ID: 2818165
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
ID: 2818255
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
ID: 2819567
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
ID: 2819802
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
ID: 2820289
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
ID: 2951653
Comment accepted as answer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I starting with php 12 143
Virtual Firewall to Filter DHCP Traffic? 23 90
Iptables and mirroring ports 4 96
Run a Radio Station (Streaming media) with web interface 10 84
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 …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

732 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