Solved

CGI Configuration.

Posted on 2002-03-06
7
378 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
[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
  • 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
Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 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