Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Why doesn´t my perlscript work with apache

Posted on 1998-06-29
Medium Priority
Last Modified: 2010-03-04
I think this is a very basic config-question.
I´m using Apache 1.3 and I want to run a simple perlscript.
I have Options ExecCGI in "access.conf" and the script has 755 rights. When I tries to execute the script I just get the sourcecode.
Question by:cl071997
  • 2
  • 2

Expert Comment

ID: 1208236
make sure the suffix is recognized as a cgi example .cgi or .pl

Expert Comment

ID: 1208237
Is the script in a ScriptAlias dir or end with the proper extension? (usually .cgi, set from AddHandler cgi-script .cgi)
Those should be sitting in srm.conf, and are commented out by default.

Author Comment

ID: 1208238
ScriptAlias was commented out, but now it´s not, but still it don´t work. (I have rebooted). The perlscript has the extension .cgi. It´s a very simple script taken from a book, so we can sxclude the script (I think). As I said - I get the whole sourcecode instead of a executed script.


Accepted Solution

tpryor earned 400 total points
ID: 1208239
I wasnt referring to the script.  Im referring to the config.
you must specify what suffix is to be executed in the config files.

Well if it is in the script alias directory it doesnt matter what the extension is.


1) ScriptAlias:

The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts. URLs with a (%-decoded) path beginning with url-path will be mapped to scripts beginning with directory-filename. Example:
ScriptAlias /cgi-bin/ /web/cgi-bin/A request for
http://myserver/cgi-bin/foo would cause the server to run the script /web/cgi-bin/foo.

2) Extensions, .cgi .pl etc
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.


Check out "http://www.apache.org/docs/misc/FAQ.html"
for more info


Author Comment

ID: 1208240
Thank you. I noticed that I made misstake when I commented out the lines about ScriptAlias. Another # was removed to in front of an ordinary textline, so the web server didn´t start. I accessed the htnml file by "open file" and tried to execute the script that way.
Well, now it works.

Thanks again


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

571 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