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.
What information AND
server paths do I need 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. PHP scripts need TO have a
.php extension.
FOR security purposes, we use Apache's suEXEC for the
execution of CGI scripts.
cgi-bin relative path = /cgi-bin/yourscript.cgi
cgi url = http://www.yourdomain.com/cgi-bin/yourscript.cgi
path to Perl = /usr/bin/perl
path to sendmail = /usr/sbin/sendmail
path to the date program = /bin/date
Do you know where can
I find some free CGI scripts?
Here are a few resources for CGI scripts:
HotScripts
FreeCode
The CGI Resource Index
Free-Scripts.Net
Script Search
My CGI script is not
working, can you help me with it?
Our support does not cover CGI script debugging. We
consider this a function of web design and we do not
offer any in-house web development or consulting
services.
Here are a few things to try when you are
troubleshooting a CGI script:
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.
Make sure that you have uploaded your script to your
cgi-bin which is one level up from your public httpdocs
directory.
Check to see if the script was uploaded to the server in
the proper format (ASCII not binary).
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.
CHECK script TO make sure that magic comment specifies
WHERE perl IS located: #!/usr/bin/ perl
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 server
paths SECTION FOR MORE info.
CHECK TO see if ALL the file permissions ARE SET
correctly. Permissions can be SET USING an 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.
PLEASE NOTE: FOR security purposes, within the cgi-bin,
script permissions cannot be SET higher than 755, OR
USER: READ, WRITE, EXECUTE; GROUP: READ, EXECUTE; other:
READ, EXECUTE (-rwxr-xr-x).
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 file
within /usr/local/plesk/ apache/vhosts/logs. 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).
Since installing a CGI script is extremely difficult for
new webmasters, you may want to consider asking a friend
with CGI experience to walk you through the process or
hire a webmaster for this part of your site.
Here are a few good online articles on installing CGI
scripts that might help:
Setting Up A Form Powered By CGI (SitePoint)
How To Install A Script (About.com)
CGI Scripts for Fun and Profit (webmonkey)
The Common Gateway Interface (NSCA)
Finally, if all else fails, you may want to consider
using a PHP script.
I'm HAVING difficulty
setting up CGI scripts, ARE there ANY other
alternatives?
Yes, CHECK out PHP. 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. The development community FOR PHP IS
gigantic, so you will be MORE AND MORE applications that
will be USING IN the years TO come.
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.
 |