Solved

Apache CGI Config

Posted on 1997-07-17
8
593 Views
Last Modified: 2013-12-20
I am running an Apache web server on Slakware Linux 2.0.29.  I think my config files are correct, but I can't execute my CGI scripts.  I'll include the following: HTML,httpd.conf, asm.conf, access.conf.  for the HTML, I've tried both of the following:
<!--#exec cgi="logger.cgi"-->
and
<!--#exec cmd="logger.cgi"-->
neither worked.
I'm pretty sure I have all the mods loaded that I need.
In my config files I have all of the following lines:
==============================================
ScriptAlias   /cgi-bin/   /<path>/cgi-bin/

<Directory /<path>/cgi-bin/>
Options +Includes
</Directory>

What could be wrong?

--Tom Langan
--tlangan@geocities.com
0
Comment
Question by:langan
  • 4
  • 4
8 Comments
 
LVL 2

Expert Comment

by:Philippe
ID: 1829144

Iangan,

When you do an exec, the path is relative to the current document.

Supposing logger.cgi is in your cig-bin directory (as this is the only one in the script alias), what you want to say is

<!--#exec cgi="/cgi-bin/logger.cgi"-->

If the logger.cgi is not in the cgi-bin directory, then you have to specify its path with ScriptAlias or ExecCgi

Hope this solves your problem.


 cheers,

   Philippe


0
 

Author Comment

by:langan
ID: 1829145
My apologies.  the actual line IS in fact:

<!-- #exec cmd="/cgi-bin/logger.cgi"  -->
although I have also tried:
<!--  #exec cgi="/cgi-bin/logger.cgi"  -->

I think the HTML is okay.  I also tried to do a "#echo var=" line, but that didn't work either.

-Again, I compiled my server with the mod_cgi and mod_include files, and I have /cgi-bin/ ScriptAlias'ed and I have
"Options +Include" in that directory.  Why doesn't SSI work at all?
0
 
LVL 2

Expert Comment

by:Philippe
ID: 1829146

> My apologies the actual line IS in fact:  
Hmmm.....

Do you get any errors in the error log?

Do cgi-scripts work? Eg: http://your.server/cgi-bin/logger.cgi

Which version of apache do you have?

What is the '+' in front of Include? If my memory serves me right, this should read "Options Include"

 Phil

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:langan
ID: 1829147
Okay.. Some more useful info:
1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above.  Is that correct?

2 - In the Apache documentation it says that the correct syntax is "Options [+/-]option"  

3 - Some CGI files work when I run them directly others don't.  I have a simple counter which works when I resolve "/cgi-bin/count.pl" .. but "/cgi-bin/logger.cgi" , which writes browser info works from a prompt, but not when I run it from a browser.  And yet another, which writes the same "logger" info to the browser window gets a "Internal Server Error" .. the error log says "unexpected end of script" , yet the script runs perfectly from a prompt?

4 - The actual "<!-- #exec ....." shows up in the "View..source code" window

5 - I'm running Apache 1.2.0 on Linux 2.0.29 on an i486-DX2 66 machine with 16mb RAM

Thanx,

-Tom
0
 
LVL 2

Expert Comment

by:Philippe
ID: 1829148

1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above. Is that correct?
 
Not sure.. From the docs you should have something like

AddType text/html .shtml
AddHandler server-parsed .shtml

and then you should call your file myfile.shtml



2 - In the Apache documentation it says that the correct syntax is "Options [+/-]option"

Sorry, I still had 1.0 docs

3-  Some CGI files work when I run them directly others don't.

First of all, there seems to be a bug in your logger.cgi Could be something wrong in the headers it generates. Can you show me the output of the that script when you run it from the prompt (and of the one that generates the Internal error). Does exec work with the correct scripts like count.pl?

What does the error log say?


 Ph

0
 

Author Comment

by:langan
ID: 1829149
Logger.cgi:
Purpose:  to write user info to a file.
Shell:  Works perfectly, writes output to a file (minus the server variables)
#exec:  Doesn't execute, leaves '<!-- #exec..' in the source code instead of replacing it with the SSI code
/cgi-bin/logger.cgi:  blank screen, doesn't write to file

i_spy.cgi:
Purpose:  to write user info to browser window
Shell:  writes correct HTML w/o server variables to standard output
#exec:  doesn't execute, leaves '<!-- #exec..' in source code instead of replacing
/cgi-bin/i_spy.cgi:  internal error: premature end of script headers

count.pl:
Shell:  writes to 'count' file (+1 every time) and writes number to standard output
#exec:  Doesn't execute, leaves "<!-- #exec.." in source code instead of replacing with SSI
/cgi-bin/count.pl:  writes correct number to browser screen

other SSI:
'<!-- #echo var=..' tag does not execute either.

-I have tried with and w/o the '+', and it doesn't seem to make a difference

-Tom
0
 
LVL 2

Accepted Solution

by:
Philippe earned 150 total points
ID: 1829150

tom,

I just installed apache a tested your setup:

there is a simple error (hope it is not a typo again!):
there should be no space between the !-- and the # in your exec directive eg:

<!--#exec cgi="/cgi-bin/test-cgi" -->

rather than

<!-- #exec cgi="/cgi-bin/test-cgi" -->

Use test-cgi as example to be sure that the problem does not come from your cgi script

Then I didn't understand what you mean by:

1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above.

What you need to have is just

AddType text/html .shtml
AddHandler server-parsed .shtml

and then you nead to have the "include" option for the directory that contains the shtml file, not the cgi files:

<Directory your_directory_with_the_shtml_files>
Includes
</Directory>

(I have it in the htdocs, so I just added Includes to the section about the htdocs directory)

For the cgi-bin directory you just need the standard thing:

<Directory your_path/cgi-bin>
AllowOverride None
Options None
</Directory>


This should solve your problem. Please accept this as answer. I'll be happy to give more info if you add more comments after that.

 Philippe

0
 

Author Comment

by:langan
ID: 1829151
Thanks for your help, Philippe.. it works great!  :-)


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I do this in Pyhton? 12 125
Access Control Entries lost in Windows folders 3 53
Using a variable to name output in powershell script 2 36
Need a good Angular tutorial 5 81
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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 …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

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