Forum Moderators: coopster & phranque

Message Too Old, No Replies

Using Apache to test CGI Scripts

         

lisad

1:39 am on May 21, 2003 (gmt 0)

10+ Year Member



I have Apache installed and running on my system, but what exactly do you do with the .cgi file and the .html file that calls the .cgi file?
Is there a specific line of code at the beginning of the .cgi file? Is there a specific place you are supposed to put the .html file?
When I open the .html file locally and try to run the .cgi file, it just tries to open it, not to run...

Does anyone know enough about this to help me?

ShawnR

9:50 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I agree with Birdman, it seems Apache is running, as it resolves '//localhost/'

I have done a few tests, and here are the results:

  • IE requests to download files that have extensions matching what is in the Windows registry (e.g .pl files), and then tries to open those files with the associated program (just like it would try and download a .doc file and try to open it using Word). Other browsers don't do this. In the absense of further evidence, I would call it an IE bug. Interested to know if anyone has an explanation, or a method to prevent it.
  • If your #! line does not point to the correct path that perl is installed on in your system, you will get the 'Internal Server error', per lisa's msg # 18. You can change the behaviour so that apache looks for the program with the equivalent extension in the registry first before trying the!# line. You do that by putting the following in the httpd.conf file:
    ScriptInterpreterSource Registry
    But then see point 1.

As a result of these points, I have a couple of suggestions:

  • Try with a different browser and/or try rename your perl script to have a .cgi suffix or no suffix instead of .pl.
  • Check that your #! line points to the correct path for perl.
  • Check out your httpd.conf file. In particular, the line which goes something like:
    ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"

    and other such lines. Check out [localhost...] and [localhost...]

    (Assuming Apache was installed correctly including its documentation)

  • Check out Xitami. The free version is nowhere near as heay duty as Apache, but for simple testing CGI it is great, and installation is a simple turn-key process; and maintenance is via gui web forms instead of clunky .conf text files. But most importantly, it displays none of the problems described above... It ignores the #! line; just tries to run the script, so if perl is installed correctly there are no problems. Also, it ignores MS IE's request to transfer the file, and just runs the cgi and serves the result. I know there are many devoted Apache advocates out there, so I'd be interested in their views on this matter.

Shawn

Birdman

7:57 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for all the help ShawnR, whippinppost and everyone else. I tried everything and then finally found some tutorial on installing apache/mysql/php/perl on Windows 98.

I just started from scratch with the default httpd.conf file and followed the tutorial, so I'm not exactly which change made my perl scripts run but, they do. :) Finally!

Unfortunately, I can't post the url because of the tos.

Thanks again!

This 32 message thread spans 2 pages: 32