Web Hosting Knowledge Base | Affordable Web Hosting Plans

CGI-BIN Directory Guidelines

Designing webpages on the web is becoming more and more complex, but more interesting too. Designing websites that have no interactive features will quickly becomes boring and uninteresting. You may ask "How can I make my site interactive and how....?" The answer is CGI or Common Gateway Interface.

Introduction to CGI-BIN Directory

You write some scripts (computer programs) and save them into your cgi-bin directory. When your visitors visit your webpage and call a script (e.g. sign a guestbook, fill in enquiry form or purchase form, etc.), this script will be executed and the results will be displayed in the browser of the visitors. The scripts that saved in the cgi-bin directory are called cgi scripts. The most common computer language that use to write cgi-bin is Perl.

CGI-BIN Basic Guidelines

Below are guidelines for using your cgi-bin directory :

  • Our servers support Perl scripts easily.
  • When uploading Perl scripts to your account make sure that they are uploaded to your cgi-bin directory and that you upload them in 'ASCII' mode; not 'Binary' mode.
  • If you are using WS_FTP uploading your scripts to cgi-bin directory, make sure that you have the proper permissions set on your Perl scripts by running the chmod command. Usually they are set as the following:

    File permission

Trouble Shooting of CGI-BIN Directory

Below are some of the most common errors when using CGI-BIN Directory:

Internal Server Error

This does not necessarily mean that the server is misconfigured or down. In fact it usually mean that: a CGI script a user has installed is not functioning correctly, and the server is detecting this. Common causes are :

  • the file is not executable,
  • there is a malformed header,
  • * it has an incorrect path reference when using a Server Side Include.

Setting Of CGI-BIN Folder

Make sure that the setting of cgi-bin is correct before trying to operate your scripts from the cgi-bin. The cgi-bin folder should have a chmod setting of 755.

Setting Of .htaccess file

The .htaccess file should have a chmod setting of 644.

Path Of Scripts

Make sure you have your path to Perl listed correctly in the script, and the HTML code of the page correctly refers to the script.

Diagnose The Errors

Many errors in Perl CGI scripts can be more easily diagnosed by adding the following line of code the top of the program.:

use CGI::Carp qw(fatalsToBrowser); This line of code will cause fatal error messages your script generates to be sent to your web browser.
web hosting knowledge base