Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.
Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.
CGI stands for Common Gateway Interface, which is a standard for external gateway programs to interface with information servers such as HTTP servers. CGI is not a program or a programming language. It is a collection of protocols (or rules) that allow Web clients to execute programs on a Web server and receive their output (if any).
Usually, the most common way for CGI to work is that the Web client (users) enters input data (if needed, some CGI programs do not need any input, such as "Hello Somebody" example mentioned earlier) , which are transferred to the server based on some protocols. The server receives the input, then passes the input to the CGI program. Then the CGI program is executed (fore example, by either sending mail to somebody via Formmail, or returning the search result back to the users if it is a search program...).
Where to Put CGI Programs?
Can we put our CGI programs(scripts) to any directory to make it run? Obviously the answer is "no". Before you write your own CGI programs, you'd better make sure whether you have permission to execute CGI scripts. Otherwise you are just wasting your time.
Most often we see people place their CGI program in server's cgi-bin directory. When you want to use your own CGI programs, you must first ask the web master to put your CGI programs in the cgi-bin directory. But this is not the only way.
Usually, the web server controls access to directories or files through Access Configuration file. Different server have different way to implement it. For example, for Apache webserver and NCSA httpd server, there are two methods for controlling access to directories:
* Global Access Configuration File
A document in server's conf directory, by default is access.conf, which controls access to any directory in your tree. For example, we can give the cgi-bin directory permission to execuate CGI program, of course we can give other directory the same permission in server's home directory. But this is not recommended for security reason. This is why cgi-bin is the most common way. This can be only defined by the web master or system administrater.
* Per-directory Access Configuration File
The default file is .htaccess, which control access to directory and its sub-directory. This can be define by the common user. But this can be restricted or completely forbidden by the Global ACF.
So Now we can see that there's two ways to place your CGI programs:
* Ask your web master to put your CGI scripts in the server's cgi-bin or other directory with CGI execuation permission.
* If not forbidden by the global ACF, you can add this statement to your .htaccess file( which should locate at your own web root directory):
This tells the server that all files have the .cgi and .pl extension are CGI programs. Of course you need to change all your CGI programs with .cgi or .pl extension.
But anyway, before start writting your own CGI program, come to see your web master first!