HTML Basix - HTML tutorials and online webmaster tools

Htaccess code generators Code generators Tutorials

Online and offline code generators

Subscribe to RSS feed
Subscribe to the HTML Basix RSS feed.

Internal Server Errors

Finding the server path and other config issues

So what IS the server path?

Sometimes the script you are installing wants to know what the server path is. If you're inexperienced with setting up scripts, this can be a hard ask. After all - you log into ftp, you see your directories - that's the server path, right? Wrong. There's more directories up above yours on the server, but you don't have access to them.

The server path is the path right back to the very start of directories on the server. This isn't a url, this will always start with a '/'. The script uses this to include any files it needs, or open files to read/write. If you get your server path wrong, your script won't be able to do the things it needs to. Some scripts detect the server path automatically, others need you to set it.

Your script may not say server path - it may say, document root, or path to this script. The document root IS the server path, it's the path to the top level of your website, ie where you'd go to In the code below I have included the script_filename for those scripts which ask for the server path to the script

So how do I find the server path?

If you created and ran the test cgi script with no problems, then finding your server path is easy. Add the following lines to your test cgi script, and open it up in a browser. This will tell you what the server path and script_filename is:

print "server path: $ENV{'DOCUMENT_ROOT'}<br>";
print "server path to script: $ENV{'SCRIPT_FILENAME'}";

So basically, your script will look like this:

print "Content-type: text/html\n\n";
print "server path: $ENV{'DOCUMENT_ROOT'}<br>";
print "server path to script: $ENV{'SCRIPT_FILENAME'}";


If your script sends emails out, it will ask you for the path to sendmail. The path is usually /usr/sbin/sendmail. You are best to use the '-t' flag at the end of this, as it's something sendmail needs and the script may not be written with the -t flag coded into it. If your script asks for you the sendmail path at the top of the script, or in a config file, then have a hunt through the script for the sendmail variable.

$sendmail = "/usr/sbin/sendmail";

Do a 'find' on your script for the variable '$sendmail' and see if it looks something like this:

open(MAIL, "| $sendmail");

If it does, then it doesn't use the -t flag and you need to set it:

$sendmail = "/usr/sbin/sendmail -t";

If the line that opens mail looks something like this:

open(MAIL, "| $sendmail -t");

then the -t flag is set, and you don't need to put it into the $sendmail variable.

Trailing slash

Sometimes a path or url will be asked for with 'no trailing slash'. What this means is when it asks for a server path or url, don't put a '/' on the end of it. For instance, these two contain a trailing slash:

$data_directory_path = "/home/www/mydomain/cgi-bin/data/";
$data_directory_url = "";

These are the same settings without a trailing slash:

$data_directory_path = "/home/www/mydomain/cgi-bin/data";
$data_directory_url = "";

The reason for stating 'no trailing slash' is because these paths will be used to construct a path/url to the files needed, and the slash will be put in by the script. If you use a trailing slash when it asks you not to, then your path/url will end up looking like this, with a double slash in:


<< path to perl Let's move on to debugging your script >>

Site Stats     
Total: 9,637,810 Total: 27,994,712
Today: 315 Today: 1,223
Yesterday: 500 Yesterday: 1,674
Past Month: 15,500 Past Month: 51,894

555 visitors in the last 24 hours
This page has been visited 7,345 times
There are currently 4 visitors online
click to see where
most people online at once:
286 visitors on 06/27/2012
   You beaut

This site is © HTML Basix 2003 - 2009