CGI programming/installation guide Manic accounts include a custom /cgi-bin directory which can
be used to install 3rd-party or custom-developed CGI scripts. The preferred
scripting language is Perl 5; compiled C is also supported.Please note: CGI programming/installation support is not included with Manic's hosting packages. If you are having problems installing a 3rd-party script, you will need to contact the script developer. You may wish to use a script from our script library. These scripts are known to work on our accounts. However, support is not provided for the installation of these scripts. If you are not familiar with CGI, your may wish to try Miva, which is included free with all accounts. Interested in
learning CGI or Perl? There are excellent articles and tutorials at WebMonkey. What script languages are supported? Manic provides the ability to run custom CGI scripts written in many interpreted languages, the most common of which is Perl 5. Compiled C is also permitted. Our Perl is version 5.005.02. Our compiler is gcc 2.7.2.1. We strongly recommend that scripts be written in Perl 5. Perl is the widely-accepted standard for CGI development, and is our language of choice. Scripts written in other interpretive languages (i.e. sh, tcl) may function correctly, but their use is discouraged. What server operating system will my scripts be running on? Your scripts will be running on FreeBSD 3.x. This operating system supports ELF binaries. The webserver is a slightly modified version of Apache 1.3.3, which uses the standard CGI/1.1 interface. WinCGI is not supported. Where do I place my CGI scripts? CGI scripts should be placed
in the What is the URL
that corresponds to my Your scripts will appear
in your What are my paths? Your actual home directory
path is of the form "
Where is perl located? Perl is found at
This is Perl 5.005.02. When
developing on your local system, run Where is sendmail located? Sendmail is located at
There is a security hole in the common " |/usr/sbin/sendmail $recipient "
invocation
What other system utilities, like sendmail, can be used? Many system utilities have Perl counterparts. To increase the performance of your CGI script, trying using the following Perl code instead of using system calls or backticks (C has many of the same utilities as Perl; consult your favorite C manual for more information):
Do I need to chmod my files? How do I chmod my files? All CGI scripts must be "chmodded"
in order to be executable by the webserver. This can be done either
with an FTP client (such as CuteFTP or WS_FTP), or using Webby. Typically,
executable file permissions should be set to
Typically, data file permissions should be set to 0660 :
To determine the current permissions of a file, view the file in your FTP client, or in Webby. When installing 3rd-party CGI scripts, please carefully follow the installation instructions, making sure to "chmod" the appropriate files and directories. PLEASE NOTE: CGI scripts may not be group or world-writable. Your CGI script will not function correctly if you "chmod" it as group or world-writable.Can I install
CGI scripts outside of my
.htaccess file
in your document root directory:AddType application/x-httpd-cgi pl cgi (etc.)Where pl and cgi are file types to treat as
executable CGI programs. This will cause the webserver to execute any
.pl or .cgi file on your site as if it were
in your /cgi-bin .A better solution is to use META REFRESH or SSI to redirect/include scripts from your /cgi-bin .
Why am I getting an "internal server error"? The webserver displays an "internal server error" (or error 500) when your script has not generated the proper CGI header. This error is rather generic, and can be caused by several factors: If using Perl, you may have uploaded your file in binary mode instead of ASCII mode. Make sure you use ASCII mode when transferring files using your FTP client.
Your script may not be syntactically correct (it may not compile). If you're using Perl, try using our syntax checker from your Account Control Panel to find errors in your script. If you do not see "syntax OK", then there is a syntax error in your script.
Your script may not be executable. Check the permissions on your script (see "chmodding", above). Make sure that it is executable, and that it is not group or world-writable. Your program may be dying before it prints out a proper CGI header. Check your error log for clues to help you identify the problem with the script. If you're uploading a binary executable, make sure that it is in a FreeBSD-compatible binary format. FreeBSD can not execute Windows binaries (.exe files) The webserver may be killing your script if it exceeds specific CGI resource limits. Scripts which fall into an endless loop, use large amounts of memory, use large numbers of CPU cycles, or stay in execution too long are subject to being killed by the webserver. Per-process limits are shown here:
Make sure your script is actually outputting a proper CGI header. In Perl, try adding the following code to the top of your script:
Don't use " When I visit my CGI script's URL, why do I see the actual code instead of the script in execution? Make sure you have placed
the CGI script in your Where is my /cgi-t directory? The How do I use SSI in conjunction with my custom CGI script? Server-side includes can
"include" the output of your CGI script using the following
code, embedded in an
For more information on SSI, please visit our SSI documentation. Can I use file locking? The use of file locking is permitted. Please note, however, that the webserver will automatically kill any process which has been waiting on a file lock for a certain amount of time (typically several seconds). The webserver will respond with an "internal server error" in such a situation. The following code fragment illustrates the use of file locking:
What is the preferred method for generating a random number? The following code fragment should be used:
which is "more random"
than the typical Why is Perl complaining about a "Literal @ now requires backslash"? The '@' character, found in email addresses, is an array symbol in Perl. If Perl is complaining about a stray '@', you most likely need to "backslash" it, by entering '\@' instead of '@'. |
CGI programming/installation -- quick reference This quick reference provides a brief summary of basic configuration information. Perl location: #!/usr/local/bin/perl (perl is version 5.005.02) /usr/sbin/sendmail (use the -t option)/usr/home/yourname.com $ENV{'DOCUMENT_ROOT'}/.. (preferred)/usr/home/yourname.com/htdocs $ENV{'DOCUMENT_ROOT'} (preferred)/usr/home/yourname.com/htdocs/cgi-bin $ENV{'DOCUMENT_ROOT'}/cgi-bin (preferred)
|
Main | Signup | Hosting | Design | Webmaster Resources | Contact Us!