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
Solved

CGI Configuration.

Posted on 2002-03-06
7
377 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

809 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