mwerner92 has asked for the wisdom of the Perl Monks concerning the following question:

So I'm using CentOS 6.7 and trying to set up a form. I can access the html using my browser, but once I input the information, the output gives me the internal server error. I've been looking for hours and can't find it. The only thing my error log says is this:

[Fri Oct 16 18:31:35 2015] [error] [client ::1] File does not exist: / +var/www/html/favicon.ico [Fri Oct 16 18:31:36 2015] [error] [client ::1] (2)No such file or dir +ectory: exec of '/var/www/cgi-bin/form.pl' failed, referer: http://lo +calhost/form.html [Fri Oct 16 18:31:36 2015] [error] [client ::1] Premature end of scrip +t headers: form.pl, referer: http://localhost/form.html [Fri Oct 16 18:31:44 2015] [error] [client ::1] (2)No such file or dir +ectory: exec of '/var/www/cgi-bin/form.pl' failed, referer: http://lo +calhost/form.html [Fri Oct 16 18:31:44 2015] [error] [client ::1] Premature end of scrip +t headers: form.pl, referer: http://localhost/form.html

My code for the html is as follows:
<html> <head> <title> Form Page Example </title> </head> <body background="light_blue_wallpaper.jpg"> <h1> Welcome! </h1> <form action=cgi-bin/form.pl method="get"> Name: <input type="text" name="user" size=40><p> Age: <input type="text" name="age" size=2 maxlength=3><p> Favorite Scripting Language: <br> <input type="radio" name="language" value="Bash">Bash<br> <input type="radio" name="language" value="Perl">Perl<br> <input type="radio" name="language" value="PHP">PHP<br> <input type="radio" name="language" value="Python">Python<br> <p> <input type="submit" value="Submit form"> <input type="reset" value="Clear all fields"> </form> All information submitted is confidental! </body> </html>

And my cgi script is as follows:

#!/user/bin/perl require("cgi-lib.pl"); &ReadParse(*input); print "Content-type: text/html\n\n"; print "<html> <body background=/var/www/html/light_blue_wallpaper.jpg> Hello <b>$input{user}</b><br> Your age: <b>$input{age}</b><br> Your favorite scripting language: <b>$input{language}</b><br> </html> </body>";

Anybody have any ideas? I'm stumped on this and getting frustrated because I feel like it's probably a stupid mistake that i can't catch.

Replies are listed 'Best First'.
Re: Internal Server Error apache/httpd
by graff (Chancellor) on Oct 17, 2015 at 02:50 UTC
    Your apache server is trying to execute a perl script that is supposed to exist at this path on the host file system:
    /var/www/cgi-bin/form.pl
    You should be able to do a shell login on the host, and see if that file exists in that directory. If you find that it's not there, you need to place a copy of your perl script there. If it is there, it might be having trouble because of unsuitable permission settings on the file (or on the cgi-bin directory, though this seems unlikely).

    UPDATE: (forgot to mention) I've never seen/used CentOS, but if it's anything like unix/linux, then your script has some problems:

    #!/user/bin/perl require("cgi-lib.pl");
    The first line should be #!/usr/bin/perl (no "e" in "usr"). Also, the "cgi-bin.pl" file must either be in that same /var/www/cgi-bin directory, or else in one of the directories that your /usr/bin/perl has in its defauilt value for @INC.

    Also, you have your last two close tags in the wrong order: </body> should be above </html>.

      Man... I knew it was something stupid. I just needed another pair of eyes on it. Where i had #!/user/bin/perl instead of #!/usr/bin/perl. I fixed it and everything works now, thanks for helping me out!
Re: Internal Server Error apache/httpd
by Your Mother (Archbishop) on Oct 17, 2015 at 03:32 UTC
    require("cgi-lib.pl"); &ReadParse(*input);

    To quote the archæology professor: That belongs in a museum!

Re: Internal Server Error apache/httpd
by Anonymous Monk on Oct 17, 2015 at 03:38 UTC