?
Solved

Apache CGI Config

Posted on 1997-07-17
8
Medium Priority
?
601 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
[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
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

801 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