Solved

CGI Configuration.

Posted on 2002-03-06
7
373 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 12

Author Comment

by:lexxwern
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now