Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help, I really need it

Status
Not open for further replies.

morpheos

Programmer
Dec 10, 2000
23
0
0
US
I am trying to set up my sistem to run cgi scripts I download apache web server when I test it if it running well it does, when I test my script with perl it is fine too.
When I try to run that script(cgi) file on the web server cause an error called INTERNAL ERROR and something about missconfiguration


my script is this:


#!usr/local/bin/perl

use CGI;

$query = new CGI;

print $query-> header;


print &quot;<html><head><title>whatever</title><head> \n&quot;
print &quot;<body>It is working</body></html>&quot;

----------------
I called it as my book recommend test.cgi and installed it in c:\apache\cgi-bin\test.cgi

when I looked it for at http:\localhost\test.cgi

cause the error which I already mentioned.


Please help me I am trying to learn cgi But I cannot even start....



 
in your apache config you need to setup cgi handlers.

i dont think that it is setup by default. it should be in your httpd.conf or in your srm.conf, depending upon what version you are running. adam@aauser.com
 
In the httpd.conf, uncomment the line that loads the perl module, and set up directory permissions to run cgi scripts, if these 2 things are done, it should work. Also, check the permissions and make sure hte file is viewable by the ggroup that apache is running as and that it has execute permission. As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Your Perl code is a little suspicious. It may be that the TT software has munched it a little. But, you are missing a slash in the first line..... it should look like..
#!/usr/local/bin/perl
not
#!usr/local/bin/perl

Also, you are mixing the use of CGI.pm and manual HTML.
[red]print $query->header; [/red]
and
[red]print &quot;<HTML><HEAD.......&quot;;[/red]
are redundant. They do the same thing. I would suggest not using CGI.pm until you get a handle on this stuff. That won't take long. Then, pick up CGI.pm to help speed the generation of code. CGI.pm has a lot of usefulness and can be a little limiting.

Also, you need semicolons at the end of your print statements.

Try this without CGI.pm,
Code:
#!/usr/local/bin/perl
print &quot;Content-type: text/html\n\n&quot;; # we need both \n here!
print &quot;<HTML><HEAD><TITLE>whatever</TITLE></HEAD>\n&quot;;
print &quot;<BODY><P>It is working now</BODY></HTML>\n&quot;;

or try this using CGI.pm
Code:
#!/usr/local/bin/perl
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html(-title=>&quot;whatever&quot;);
print &quot;<body>It is working now</body></html>&quot;;

you can make sure the Perl is working independent of the web server.....
>perl -c test.cgi

That will do a syntax check on the code. If you have a typo or don't have CGI.pm installed, you will get a complaint. If you don't get a complaint, then the Perl is OK, and the problem is likely where liciddream suggests, in the httpd.conf file.

'hope this helps.




keep the rudder amid ship and beware the odd typo
 
Make sure the file permissions allow execution. CHMOD 755. Also, make sure your webserver user (usually &quot;nobody&quot;) has permission to access that file. If not, CHOWN it, or use a wrapper. Then, make sure to set up the cgi handlers and directory permissions like suggested above.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
I had the same problem when i first start using a local host, check the following points:

1)did you remember to start apache from the start menu before calling the script from your browser?

2)path to interpreter:
if you installed apache in your c drive,
your path to the perl interpreter is not
#!usr/local/bin/perl
try #!C:\Perl\bin\perl.exe

3)did you Configure apache after installation?if not:
open notepad, go to c:\apache\conf\httpd.conf
find the line ServerName, uncomment it & change this to:
ServerName 127.0.01

4)form Action:
makesure your action tag is:
<form action=or
<form action=makesure the .pl or .cgi extension is correct.

5)are your document stored correctly:
save html docs in c:/apache/htdocs/filename.html
save .cgi/.pl docs in c:/apache/cgi-bin/filename.html

This was how i set up my local host on win98 and it works all the time.

good luck

ratz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top