Home | Web Design Tutorials | Free Graphics | Custom Graphics | Newsletter | Products | Specials | SEO | Sound Effects | Benefits | Login | View Cart |
Beginner's Guide to Installing CGI ScriptsThis tutorial is intended for those with little or no experience installing CGI scripts. It only covers installing scripts you can buy or find for free, it does not cover writing or customizing scripts.What is a CGI script?CGI is an acronym for Common Gateway Interface. It's not a programming language as many novices believe, it's actually a small, uncompiled software program that provides a way for a web-server to communicate with a browser in ways not possible with HTML alone. Most CGI scripts are written in a programming language called Perl. Although other languages can be used to create CGI scripts, Perl is by far the most common, so this tutorial will focus on Perl scripts.A Perl script is really just a common text file written in the Perl language, and saved with a .cgi extension (or .pl extension for some scripts). CGI scripts are server side scripts, which means the scripts are executed on the server with only the output of the script shown in the browser. This is the opposite of JavaScript, which is a script contained within an HTML page and executed client side by the viewers computer. Requirements
ConfigurationThe first thing you need to know is the path on your server to the Perl interpreter. If you have cgi-bin already in place there's a good chance there may already be a CGI script in it. View the script to see the correct path to Perl. It will be the first line. You can also usually find it in your web host's FAQ pages, set-up message, in yoru site's control panel, or in the support documents provided by your web host.The most common cause of error among webmasters new to installing CGI scripts is using an incorrect path to the Perl interpreter. The first line will look something like this:
#!/usr/bin/perl ...or... #!/usr/local/bin/perl
That first line may or may not have to be changed. The path has to be the correct one for your server or it won't work, but in my experience about half the time the script you download will have the correct path.
Check the Perl Script for InstructionsWhile you've got the script open to check the path to Perl, look at the top of the script for comments regarding any other variables that need to be configured. Often there are none, but occasionally you'll find one or more. Read the comments to see what to do. Comments in Perl are lines that start with the hash mark ( # - also called the pound sign).
# This would be a comment in a Perl script. One thing that is occasionally required that you might find directions for in the comments is that the path to your site may be required somewhere in the script. The path is usually not the same thing as the web address (URL). My URL is http://www.boogiejack.com, but the path to my site ON THE SERVER is like this: /mmt/web/users/boogiejack/wwwThe above example probably won't work on your server, even if you change the domain name portion from mine to yours. The paths are different on almost every server. If you use WS FTP, you'll be able to see the complete path in the window above the server-side files when you connect. Otherwise, check your web host's support, FAQ, or set-up pages. InstallationOnce you've configured the script for your server, it's time to upload it. Again, when uploading CGI scripts you must upload them in ASCII mode. The other option is binary mode, which is used for images and other types of binary files. A CGI script is a text file so it's should be uploaded in ASCII mode.Technically, CGI scripts can be executed from any directory, but most hosts only allow it from the cgi-bin, so that's where you should upload the script to. After uploading the script you still aren't finished. You must set the correct file permissions for the script and any other directories and files the script uses. Understanding File PermissionsUNIX servers allow you to set different levels of access to a file for different groups. There are three groups in terms of file access, and three different permission types each group can receive. You don't really have to understand this part to set permissions if you know what permissons the script should have, but it's here for those that really want to know. Feel free to skip down to Setting Permissions if you're in a hurry.The groups are:
The permissions are:
Setting PermissionsPermissions are set with a UNIX command called CHMOD. Don't worry, you don't have to know UNIX commands, it can be done quite easily with your FTP client. You should be able to find the permissions you need via the source where you got the script or within the script itself, or in a Read Me or set up file that may have came with it. Many scripts require a permission of 755, so if you can find the correct persmisisons you might try guessing 755.To set file permissions using WS FTP, left-click the script to highlight it, then right click on the highlighted file and a pop-up menu will open. Choose chmod(UNIX) from the pop-up menu. Below is a screen capture of the Screen for setting file permissions.
Permission assignments:400 read by owner 040 read by group 004 read by anybody (other) 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybodyHere's an exercise for you. You have a script that calls for the following permissions:
Owner: read, write, execute Before looking at the chart below for the answer, see if you can add up the correct numbers according to the permission assignments and come up with the correct CHMOD setting number. Here is the answer worked out in living grayscale for you:
You peeked at the answer without trying to work it out for yourself didn't you? Tsk, tsk . . . how are you going to learn that way? As you can see, if you add up the sub-totals in the right hand column in the table above, you'd get a file permission of 765. The numbers in each column are pulled from the permission assignments as shown above the table. TroubleshootingIf you're reading this tutorial, you're likely inexperienced at installing CGI, and the bad news is that there are many things that can go wrong. To compound the problem, the thing that is wrong isn't likely to be obvious to you. Here are the three most common errors and possible causes:
Whew! That was a humdinger, wasn't it? Yeah, you loved it though. :o) |
Almost a NewsletterChanging list hosts. Will post a new subscribe form shortly.Did you know...The member's site has about 100 standards compliant HTML and CSS tutorials, 31 handy reference charts, reprintable content, web graphics, exclusive fonts, free software, free ebooks and more? All this for less than 9 cents a day! [ Details ] |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Home | Web Design Tutorials | Free Graphics | Newsletter | Products | Specials | SEO | Sound Effects | Press Room
Sitemap | Member Perks | Member Login | About BoogieJack.com | Contact | Privacy Policy | Copyright Policy | Links
|