How To: CGI
What
is CGI?
HTTP
allows you to present text and images to your users on the world
wide web, however the text and images are always static and there
is no way for the user to input data. CGI scripts are probably
the most popular and easiest ways to create web pages that are
dynamic and allow your users to input data. The most popular languages
used in CGI scripts are Perl and C. There are thousands of CGI
scripts available on the Internet and if you can't find one you
can write your own, or have one written for you. We have provided
you with a few scripts that we have found useful and we think
you may as well. They include a form processor and page counter.
We also have a shopping cart system if you need one.
What you need to make CGI work:
The
first thing you need to have in order to use CGI scripts is access
to your servers CGI-BIN directory. All of our server packages
include CGI-BIN directories with unlimited access to them.
You
will then need to configure your script. This help section can't
cover all of the aspects of configuring your scripts. The script
you have should instructions on how to configure the script and
install it. There are some settings that are fairly common to
Perl scripts that you will find useful
- The location
of Perl. All Perl scripts require this and it will be on
the first line of code. On our servers the location of Perl
is:
#!/usr/bin/perl
Be sure that
the first line of code is exactly as it is above.
- Absolute paths
and URL's are also common in script configurations. On our
servers absolute paths usually start with the directory
/virtual/yourdomain.com/. URL's should always start with
http://yourdomain. If you are unsure of your absolute path
please e-mail us at [email protected]
and we'll e-mail you your abosolute path.
- Many scripts
need to use the sendmail and date commands. On our servers
the location of sendmail is /usr/sbin/sendmail and the location
of date is /bin/date.
Once
your script is configured, upload it to the CGI-BIN directory
on your server using your FTP client. Be sure to upload using
the ASCII mode NOT Binary or your script will not work.
After
uploading set the permissions on the script. The script's documentation
should tell you what you need to set the permissions to. Many
FTP clients have options to set the file permissions. If yours
does not open a tech support
ticket and request a file permission to be set and we will
change it for you.
Pre-Installed Scripts:
We have
included a few scripts that you may find useful and are already
installed and configured in your CGI-BIN directory.
FormMail
Forms
are a common method of letting your users send you information.
The FormMail script written by Matt Wright is an easily configured
script which allows you to place a form on your web site and
have the users input e-mailed to you. Go to Matt's
Script Archive to see full documentation on this script
and how to use it. There are certain options that must be configured
by the user in order for the script to work properly.