?
Solved

CGI Configuration.

Posted on 2002-03-06
7
Medium Priority
?
387 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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 375 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

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…
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…
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 the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

743 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