Solved

CGI Configuration.

Posted on 2002-03-06
7
376 Views
Last Modified: 2013-11-18
For Some reason my Apache does not run CGI Script and gives me Error 500 or Error 404.

Here below is the config of my server related to CGI.
ScriptAlias /cgi-bin/ "E:/root/lhn/root/cgi-bin"
<Directory "E:/root/lhn/root/cgi-bin">
   AllowOverride None
   Options All MultiViews
   Order allow,deny
   Allow from all
</Directory>
    AddType script .cgi
    AddHandler cgi-script .cgi
    AddType script .cgi
    AddHandler cgi-script .pl


My Perl is installed in the following dir.
E:\req\perl\bin

There's no problem with the Shebang.

System info.
Win XP Professional
Apache 1.3.23
Perl 5.61

Is there something im doing wrong \. please help.

Regards/
0
Comment
Question by:lexxwern
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:johnnyp
ID: 6844131
Check you webservers error log, it should provide a little more of an indication as to what is going on as it is the webserver that is unable to do something.
0
 
LVL 15

Expert Comment

by:samri
ID: 6844270
This is the default httpd.conf that comes with my Apache (Win2K).

The only thing I noticed the difference is; missing slash (/) at the end of "cgi-bin" in ScriptAlias directive.

    ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"

    #
    # "C:/Program Files/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "C:/Program Files/Apache Group/Apache/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

Your config.
-------------
                      ScriptAlias /cgi-bin/ "E:/root/lhn/root/cgi-bin"

                       <Directory "E:/root/lhn/root/cgi-bin">
                         AllowOverride None
                         Options All MultiViews
                         Order allow,deny
                         Allow from all
                       </Directory>

---
And the AddHandler can take multiple file extension.  Just a comment;

AddHandler cgi-scripts .pl .cgi .exe  # just example,.

And make sure you had "Options ExecCGI" in the respective <Directory> ...</Directory> you want the scripts to be executed by the server, otherwise you will get an error.
0
 
LVL 12

Author Comment

by:lexxwern
ID: 6846586
Ya. That sort of helped samri...
but now suppose i have a sub directory in my cgi-bin.
Then What'll me <directory>.......</directory> be.

What should my config be...
<Directory "E:/root/lhn/root/cgi-bin/YaBB">
  Options ExecCGI MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

<Directory "E:/root/lhn/root/cgi-bin">
  Options ExecCGI MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
.!?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 12

Author Comment

by:lexxwern
ID: 6846589
Ya. That sort of helped samri...
but now suppose i have a sub directory in my cgi-bin.
Then What'll me <directory>.......</directory> be.

What should my config be...
<Directory "E:/root/lhn/root/cgi-bin/YaBB">
  Options ExecCGI MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

<Directory "E:/root/lhn/root/cgi-bin">
  Options ExecCGI MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
.!?
0
 
LVL 15

Expert Comment

by:samri
ID: 6847194
lexxwern,

In order for certain code to be executed, there is two options, (1) ScriptAlias, or (2) AddHandler directives.

For case #1, you can either defined another

                        ScriptAlias /yaBB-cgi-bin/ "E:/root/lhn/root/cgi-bin/YaBB/"

                       <Directory "E:/root/lhn/root/cgi-bin/YaBB">
                        Options ExecCGI MultiViews
                        AllowOverride None
                        Order allow,deny
                        Allow from all
                       </Directory>

                        ScriptAlias /cgi-bin/ "E:/root/lhn/root/cgi-bin/"

                       <Directory "E:/root/lhn/root/cgi-bin">
                        Options ExecCGI MultiViews
                        AllowOverride None
                        Order allow,deny
                        Allow from all
                       </Directory>

This should work.  And in fact, since YaBB is already in E:/root/lhn/root/cgi-bin/ directory, you would not need to defined another ScriptAlias for that.

Another option is (#2), you can have all your scripts to have a common extension, for and use a combination of AddHandler and Options ExecCGI to achive the same purpose.

I hope this would help.
0
 
LVL 12

Author Comment

by:lexxwern
ID: 6852551
samri, u mean to say that if i have  ScriptAlias i don't need AddHandlers?
I just tried this case. didn't work.
And i tried the opposite. No luck either.
please comment further.
lexxwern.
0
 
LVL 15

Accepted Solution

by:
samri earned 125 total points
ID: 6853211
ScriptAlias and AddHandlers are independent of each other.  ScriptAlias with it's associative <Directory> directive, will define a directory which all files in that directory will be treated as CGI program.  AddHandler however, will define files extension which the server will treat as CGI program.  But the Option ExecCGI needs to enable in that specified <Directory> for the option to take effect.

Regardless of which option you opt to choose, the CGI program itself must conform to CGI standard.  Not all program will run.  The first thing to look for is the logfile.   Most common error that might pop up would "premature script header" (or similar wording).  This indicates that your scripts is the one that causes the error, and not the server config.

It would be helpful (on you get the Server config right), watch the logfile (error_logs), for error when you execute the scripts (from you Web browser).

If you would post it here, it would certainly help us to diagnose the problem.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

805 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