Debugging internal server errors (premature end of script headers) part 3
Path to PerlOpen up your scripts in a text editor. Notepad is about the best to use for this, it's plain, simple, and doesn't change any formatting in any way. The very first line should be the 'shebang', or path to the perl interpreter on the server where your website is. It will look something like '#!/usr/bin/perl'. The most common locations are /usr/bin/perl, and /usr/local/bin/perl. If you know where perl is located, check that the path is the same. If your scripts can't find perl, then they won't be able to do their stuff.
* make sure the path to perl is the very first thing on the page. There shoud be NO space before the '#' - this character should be on the first line, first character, or you will get an error!!!
How to find the path to perlThere are several ways you can find the path to perl.
- If you have telnet/ssh access to your website (if you don't know if you have, you probably haven't!) then log in to your account using telnet or ssh, and at the command line, type in which perl. It will return the path to perl.
- Check any help files, documentation or forums for where your website is hosted. Chances are, somewhere in them it tells you what the path to perl is.
- Create a basic script which will help you to determine the path to perl.
Create a basic script to find out what your settings should beTo create a basic script, open up notepad and copy and paste the following into it:
print "Content-type: text/htmlnn";
Note that there's a ';' at the end of the line after 'test'. This has to stay there!!! Save this script as 'test.cgi'. Make sure you choose 'all files' from the dropdown list on the save box, otherwise it will save it as test.cgi.txt.
Upload this file to your website. You're best to upload it into the cgi-bin, as your webhost may not allow cgi files to run outside of the bin, or may not have set it up that way.
Chmod test.cgi to 755. Do this by right clicking on the file in ftp, and choosing CHMOD from the dropdown list. Enter the number 755 in where the number 644 is. If you can't work out how to do this, check the Chmod section on the previous page.
Once your file has been changed to 755, open it up in a browser. This means you will go to the url something like http://www.yourwebsite.com/cgi-bin/test.cgi. If everything went right, you should see 'test' on the page. If you get an error page instead, then we need to fiddle with some more stuff.
Your test script worked fine
Great! This means that you've found the settings you need to use. Make sure the path to perl is the same in the script you are trying to install as it is in the test.cgi script. Also, set chmod the same as the test.cgi script.
Your test script erred
If you received an error page instead of the word 'test', then chmod test.cgi to 777. Open up your page again, and see if you can see the word test. If you can't, then you need to change the path to perl. Open up the test.cgi script, and change:
|#!/usr/bin/perl to #!/usr/local/bin/perl|
If it still errors, email your host and ask them what the path to perl is.