JUMP TO CONTENT

Laughing Squid Web Hosting

 Laughing Squid Web Hosting

Home » Frequently Asked Questions (FAQ) » CGI

CGI

  1. What are CGI scripts? #

    CGI (Common Gateway Interface) is a process used by the server to pass information between the user and an application on the server. With CGI access, you can install Perl scripts on your website for such things as feedback forms, guestbooks, counters, and so on.

  2. What information and server paths are needed to run a CGI script? #

    CGI scripts must be run from the cgi-bin directory which is outside the httpdocs directory. CGI scripts need to have a .cgi or .pl extension.

    For security purposes, we use Apache’s suEXEC for the execution of CGI scripts.

    cgi-bin absolute path = /var/www/vhosts/yourdomain.com/cgi-bin/yourscript.cgi

    cgi-bin relative path = /cgi-bin/yourscript.cgi

    cgi url = http://yourdomain.com/cgi-bin/yourscript.cgi

    public directory absolute path = /var/www/vhosts/yourdomain.com/httpdocs

    path to Perl = /usr/bin/perl -w

    path to Python = /usr/bin/python

    path to Tcl = /usr/bin/tcl

    path to sendmail = /usr/sbin/sendmail

    path to the date program = /bin/date

  3. What version of Perl are you running? #

    Perl 5.8.5

  4. Where can you find more info on Perl? #

    Perl.com

    Perl Mongers

  5. What other scripting languages are installed? #

    PHP (see our PHP FAQ)

    Python

    TCL

    We do not provide any specific support for any scripting languages, including Perl. If you decide to use them, it is assumed that you know what you are doing and use them at your own risk.

  6. Do you know a good resource for free CGI/perl scripts? #

    Check out ScriptSearch.com.

  7. A CGI script is not working, are you able to help install and troubleshoot it? #

    CGI script debugging is beyond the scope of the support that we provide. This is a web development issue and we do not offer any in-house web development/consulting services. We make sure that CGI is enabled for your website, that Perl is working properly on the server, that you are provided with the correct path information and we can even help point you in the right direction, but we do not have the resouces to debug, install or develop your scripts.

    Here are a few things to try when you are troubleshooting a CGI/Perl script:

    1. First of all, thoroughly read through the instructions that came with the script and also check the website where the script was downloaded for troubleshooting info and user forums.
    2. Make sure that you have uploaded your script to your cgi-bin which is one level up from your public httpdocs directory.

      NOTE: Do not create subdirectory named cgi-bin in your /httpdocs directory or your CGI will not work, the /cgi-bin directory is a parallel directory to /httpdocs.

    3. Check to see if all the file permissions are set correctly. File permissions can be set using your control panel’s file manager or a FTP program that allows permissions to be set on transfer. Typically scripts are set to be 755, user: read, write, execute; group: read, execute; other: read, execute (-rwxr-xr-x), but you should always check your script instructions or README to be sure.

      NOTE: For security purposes, within the cgi-bin, script permissions will not work when set higher than 755, or user: read, write, execute; group: read, execute; other: read, execute (-rwxr-xr-x). This is one of Apache’s suEXEC security features (all of our servers run CGI under suEXEC).

    4. Check to see if the script was uploaded to the server in the proper format (usually ASCII not binary).
    5. Make sure that there are not any DOS/Windows carriage returns (ie. ^M) at the end of each line in the script. This is usually caused by a text editor or FTP program that is not properly uploading your script in a Unix/Linux format. If this is happening, try changing your code line break settings or upload settings to Unix/Linux.

      Here’s how this is done in Dreamweaver: From the menu, goto Edit > Preferences > Code Format, then change Line Breaks to “LF (Unix)”.

      The ^M is actually the ASCII LF character. Windows uses CR/LF, Mac uses CR and UNIX uses LF as line terminators. Most FTP programs translate the line terminators when doing an "ASCII" or "text" transfer, but they do not do the translation if it is a binary transfer. The problem with CGI files is that the FTP program may not recognize the extension, so it assumes that it is a binary file. Turning off the auto detect feature and manually transferring the CGI files as ASCII should solve your problem. Another option would be to add .cgi/.pl to the list of ASCII file extensions.

    6. Check script to make sure that magic comment specifies where perl is located and that warnings are enabled: #!/usr/bin/perl -w
    7. Verify that all the paths are correct, including your public directory path. Do not use the "www" part of your domain in your public directory path. See our CGI server paths section for more info.
    8. If you have checked all the above and are still receiving an "Internal Server Error" when trying to execute the script, check the domain’s error_log. Most likely you will see a "Premature end of script headers" error which usually means that the file has been corrupted in some way. This can occur when the script is uploaded or when the script is edited and saved in certain text editors. Usually the file is corrupted with the (line feed) hidden character which is commonly mistaken with the (carriage return).
    9. Since installing a CGI script is extremely difficult for new webmasters, you may want to consider asking a friend with CGI/Perl experience to walk you through the process or hire a webmaster for this part of your website.
    10. Here are a few good online articles on installing Perl CGI scripts

      Perl 101: How to install a basic Perl script on a Web server (ServerWatch)

      How To Install A Script (About.com)

      The Common Gateway Interface (NCSA)

    11. Finally, if all else fails, you may want to consider using a PHP script.
  8. Are there any alternatives to CGI scripts that are easier to install and configure? #

    Yes, check out PHP, a very popular and dynamic an open-source scripting language. It is much easier to configure (no permissions to set, it can run from any directory, etc.) and much of what you can do with a CGI script you can do using PHP.

  9. How do web users setup CGI scripts, do they need to use a cgi-bin? #

    Web users (ie http://domain/~username) do not need to use the site’s main cgi-bin. They can setup CGI scripts to run anywhere within their web space.

  10. Is it possible to install Movable Type on a website? #

    Yes, we have added all of the perl modules necessary for Movable Type to our servers. If you do install it on your website, please make sure to keep it updated and patched to prevent possible security problems. For more info on installing and updating Movable Type, please see the Movable Type website.

    Movable Type has had a few problems with commment spam, so if you plan on installing Movable Type, please make sure to read through and follow the recommendations in their “Guide to Comment Spam”. Also, some excellent tips on fighting comment spam can be found in the “Concerning Spam” tutorial from the “Learning Movable Type” blog. If you plan on using Movable Type’s comments or trackback feature, you need to be running the latest version. If your installation of Movable Type is being exploited to send spam or is creating a high load on our server or you are running the latest version, then it may be necessary for us to delete your mt-comments.cgi and mt-tb.cgi scripts.