|
Implementing Custom CGI scripts
Powerful Hosting provides a rich platform for devoloping dynamic content
as well as basic cgi scripting. We support over 20 different languages including PHP, Perl, Bash,
Tcl, Java, C/C++, Python and many more. PHP is our language of choice and we provide
extensive support for it. Currently Powerful Hosting does NOT support
ASP (active server pages) or Cold Fusion on our standard hosting accounts. If you require
either of these languages please contact customer service for more information.
The following guide should provide the basic information required to install and run cgi scripts
on our servers. If you have further questions not covered in this document, please contact
support@powerfulhosting.com or 888-486-4533. We provide prefessional consulting and software
developement services.
Quick Reference
| Perl (v5.6.1) Path | /usr/bin/perl |
| Sendmail Path | /usr/lib/sendmail |
| CGI Path | /home/username/www/cgi-bin |
| CGI URL | http://yoursite.com/cgi-bin/ |
| FTP Host | ftp.powerfulhosting.com |
| MySQL Host | localhost |
Installing Scripts
There are three different ways to run scripts on our servers. The method you choose depends on what
your script requires. If you are writing your own php script you will use the script handler method
other wise we recommend using the .cgi method for the greatest flexibility and organization.
.cgi Method
With this method you may place your scripts anywhere within your web directory (/home/user/www/) as
long as the filename of the script ends in .cgi and the script has been set executable (see below).
This allows you to organize your files into subdirectories without loosing the script functionality.
For example if you had a script called formmail.pl you would upload this file to /home/user/www/formmail.cgi
rather then /home/user/www/cgi-bin/formmail.pl. This is the recommended setup for all cgi scripts except
those written in the PHP language or prefab scripts that have already been designed to work with /cgi-bin.
/cgi-bin/ Method
Any scripts uploaded to /home/user/www/cgi-bin and set executable (see below) will be run as cgi scripts.
There is no restriction to filenames. This is the traditional method for running cgi scripts. Many off the shelf
scripts have been designed to run out of this directory.
Handler Method
The handler method allows scripts to be handled by a file handler. This is an extension of the webserver
that parsers the script rather then executing script as a program. The main advantage to users of this method
is that they do not need to go through the hassle of setting their scripts executable. Currently we only support
handlers for PHP scripts. To use php scripts you must first enable the php script handler. To do this go to
the website features section of your control panel and click "Enable PHP Handler". Then upload your script with
a .php extension.
Here are some helpful tips to follow when installing scripts;
Shell Scripts (UNIX only)
- Upload to your cgi-bin directory to ensure proper file permission
settings
- Upload in ASCII transfer mode (and NOT BINARY mode)
- The first line of each script must read: #!/bin/sh , #!/bin/csh or
#!/bin/ksh based on whichever shell scripts you prefer using.
- Reference the script using /cgi-bin
- Always remember to include echo "Content-type: text/html\n\n"
Perl Scripts
- Upload to your cgi-bin directory to ensure proper file permission
settings
- Upload in ASCII transfer mode (and NOT BINARY mode)
- The first line of each script must read: #!/usr/local/bin/perl
- Reference the script using /cgi-bin
- Always remember to include print "Content-type: text/html\n\n";
or alternatively using the Perl module CGI.pm (If you do not, your scripts
will not run and you will get an Internal Server Error message).
use CGI qw(:cgi-lib :standard);
print header();
If a script calls another file within your account, but the script does
NOT require a URL, you need to use the system path. Instead of using the
absolute path to your home directory ("/home/username/www"),
you should instead use the DOCUMENT_ROOT environment
variable ($ENV{DOCUMENT_ROOT} in Perl) to determine the path of your files
or programs within a script.
Change this: /home/username/www/fact.html
To this: $ENV{DOCUMENT_ROOT}/fact.html
- The system path to the sendmail program on our UNIX
server is /usr/lib/sendmail
- The system path to the date command on our UNIX server
is /bin/date
|