How Do I Install A CGI Script? Part 2
Make sure you have the complete list of files that have to be installed. Let's learn how to use any script file with these 5 easy steps.
1. Follow the installation document. You will be asked to open a .cgi or .PL file in a text editor as the first step. In almost any file of this type, you find the following:
# ! /usr/local/bin/path
This line must be in your Perl script as the first line to get it to run right. It often causes a 500 Server Error if this is not set as your first line or if it is set in the wrong place. Copy the path of Perl program in your server noted down during the previous lesson as the first line of your program, with' # !' in the front. Should this command fail, ask your system administrator if they have Perl installed on their server and to where you should point this line.
2. Keep reading the .cgi or .PL file, you'll find some lines telling about the directory path and URL settings of your cgi-bin directory. Change the cgi-bin path in this file to the one noted down. Follow the other instructions in the script file given as Remarks. (All the lines which you find that start with # symbol are remarks or comment statements) Sometimes the author gives you a warning like "You should not edit anything below this". Its advisable to follow these warnings. You make any changes violating this warning, at your own risk. Then, you may be asked to open some more script files to do the same settings as above. Go one step at a time carefully. It is easily done. Let us pause for a moment here and learn a little more about the cgi-bin.
The cgi-bin is a special directory in the server where we keep all the files which require security. Limiting access of CGI scripts to trusted users is necessary, since the CGI opens up a lot of security risks. Therefore, most web platforms only allow files inside of a cgi-bin to be executed. This can be changed. If the cgi-bin has not been enabled on your server, or if you don't have one, ask your system administrator to give you the privilege to execute CGI scripts on your server.
A cgi-bin is needed to run these scripts unless your system administrator has turned on ExecCGI, which enables .cgi extensions to be used in any directory. To find out if you can use CGI scripts, your best bet is to ask your system administrator if you can. He/She may opt to give you a cgi-bin in your directory, turn on ExecCGI or check your script and then place it in the server cgi-bin.
Just make sure you set all variables to reflect any changes you have to make to the location of files and scripts by double checking.
3. Now you are ready to upload. You can upload all the files after completing all necessary changes There are two modes of uploading, ASCII and Binary. You can upload the .cgi, PL, .confide, .cfg, .setup and .txt files in ASCII mode, because basically they are text. Upload any image files like .jpg or .gif in Binary mode. If you don't follow this you will not be able to execute the script. If you upload any script files in Binary mode it will crash the script too. If you find that you have done it accidentally, delete the server file and upload a fresh copy from your local hard drive, carefully this time!
4. Now you would like to change the permissions of the script files but first you need to know that this is place where people often make mistakes and fail in installing scripts. You should be clear about chmod(changing mode or permission), so don't skip this area. File permissions allow read, write, and execute access to users based on their user identification (also known as uid), and their membership to certain groups. You can use the command: chmod to change a file's permissions. Here is an example:
chmod 755 form.cgi
Chmod is a UNIX command which changes the security settings for a particular file, giving users and groups permission to read, write, and/or execute certain files.
For the script files, you need to make them executable. The code for that is 755. You only need to do this once. When you FTP the file again, it will overwrite the old file but the permissions will stay the same. Also note that some FTP software (like WS_FTP) have a builtin option to let you change the permissions without having to telnet to the server.
Your server however has to support that feature. If you are interested in setting permissions from your FTP program, keep reading this section for more information on exactly what the permissions numbers (755 or 666) mean; or you can jump ahead to step 5, if you are not curious.
After you chmod the file, type in ls -Ls (that's Ls[space][dash]Ls) and it will show a directory listing. In CoffeeCup Free FTP you can view it by pressing the Refresh button. Notice that next to the .cgi files, there is something that looks like:
- r w x r - x r - x
For our purposes, we can ignore the first symbol. The "r" symbol stands for read. The "w" symbols stand for write. And the "x" symbols stand for execute. Now, the above line of symbols is actually divided into 3 categories. (Ignoring the first symbol as stated above) the first three symbols define the permissions for the file's user (probably you). The second set of three symbols define the permissions for the file's group. (If you and many other employees are working on a web project together, you might be set up on the server as a group so you can edit each other's work). The third set defines the permissions for everyone else ("others" or the "universe"). So by doing chmod 755 filename.cgi, you or your group can read, write, and execute the file. Everyone including the Internet browsers, can read and execute the file.
So what does the number 755 stand for? Notice that this has 3 digits. As you would expect, those 3 digits correspond to the three different sets of permissions (file's owner, file's group, and others). Here are what each individual digit stands for:
1 = - - x
2 = - w -
3 = - w x
4 = r - -
5 = r - x
6 = r w -
7 = r w x
Therefore: 755 = r w x r - x r - x (We don't have to bother about the leading character).
5. After you have the permissions set, jump over to your browser and try to run the script. Your installation help file will tell you which URL you need to open. It could be a .cgi, PL or a .html file.
Provided by Stylusinc.com
Located at http://www.stylusinc.com/cgi_installation/chapter9.htm
|Home | Software | Support | Knowledge Base | Affiliates | Contact | Take The Tour|
Copyright ©1994-2009 SiteInteractive.com All Rights Reserved.