Re: How to configure Apache for running perl scripts.
by dsb (Chaplain) on Aug 06, 2004 at 13:57 UTC
|
You have to configure Apache to handle Perl scripts. This might be a good place to start before you go showing off your source code :).
You also need to print out valid HTTP headers before you can print any web content. Something your tiny script does not do.
print "Content-type: text/html\n\n";
or even better:
use strict;
use CGI;
my $q = CGI->new();
print $q->header("text/html");
dsb
This @ISA my cool %SIG
| [reply] [d/l] [select] |
|
Now I have added the lines you have specified..
But now it is telling that "you do not have permission to access a.pl on this server".
BUT I DID "chmod 777 a.pl".
In /httpd/logs/errlog file it is mentioned that "optionsExecCGI is off in this directory /var/www/html1/a.pl"
suEXEC mechanism is enabled
| [reply] |
|
| [reply] |
Re: How to configure Apache for running perl scripts.
by sunadmn (Curate) on Aug 06, 2004 at 13:59 UTC
|
Well I am sure there can be many different levels of issues here, but first I would suggest checking that the script is executable this file should be chmod 755. Also you might need to ensure your Apache build was configured with suexec enabled.
| [reply] |
|
Yes I had done chmod 777 a.pl, but it is still displaying the contents of the file.
And how to check if Apache is build with SUexec or not
| [reply] |
Re: How to configure Apache for running perl scripts.
by Gilimanjaro (Hermit) on Aug 06, 2004 at 14:16 UTC
|
Your combining two different ways of enable scripts:
<Directory "/var/www/html1">
ScriptAlias /cgi-bin/ "/var/www/html1"
</Directory>
Enables your scripts under http://myIPaddress/cgi-bin/a.pl
AddHandler cgi-script .cgi .pl
Would enable your script to run everywhere in your DocumentRoot, but you'll also need:
<Directory "/var/www/html1">
Options +ExecCGI
</Directory>
ScriptAlias sets up an alias, and does the +ExecCGI implicitly for the location.
If you don't want to be bound by your location, you need to explicitly add ExecCGI rights, and tell Apache to recognize the .pl extension.
Please consider using mod_perl though, if you want to be nice to your server... | [reply] [d/l] [select] |
|
I have added "Options +ExecCGI" line as you told.
But there are 2 similar places where i can add. And I have added the line in 2 places.
But in error log it is still saying that "ExecCGI is not enabled".
| [reply] |
|
The error message means:
- Apache has found the script at the url you specified
- Apache recognizes the extension, and is trying to use the cgi-script handler
- But Apache's failsafe mechanism which required that ExecCGI is explicitly enabled is blocking you
Look for other 'Options' directives, maybe below your +ExecCGI one, that disable it again (maybe not explicitly, but possibly by specifying None).
Please take a good look at Apache's documentation on the Option directive and Directory, Location and Files blocks. Also make sure there are no .htaccess files around which override your Options directives. Without your complete apache config it's hard to exactly determine the exact cause. If you can't find it with these tips, put it on the web somewhere, and send me a message with the url. I'll have a look at it for ya...
| [reply] |
|
|
Re: How to configure Apache for running perl scripts.
by trantor (Chaplain) on Aug 06, 2004 at 14:18 UTC
|
Did you add something like Options +ExecCGI between <Directory> and </Directory>?.
What does the error log say? In my experience, you can solve 95% of your configuration problems by looking at it.
| [reply] [d/l] [select] |
|
the error log says ExecCGI is off.
There are lots of <Directory> tabs present.
So can you please specify in which directory tab I should put the "Options +ExecCGI"
| [reply] |
|
Er, in all the directories where you want CGIs to be executed of course.
Looking at your configuration snippets, the <Direcory "/var/www/html1"> section seems like a good candidate.
| [reply] [d/l] |
|
|