next up previous contents index
Next: Environment Up: Web Server Previous: Simple HTML   Contents   Index


CGI Scripting

CGI is short for Common Gateway Interface. The idea behind CGI is that you have a program that runs and generates a web page instead of an unchanging text html file. CGI is also able to read information from its environment, a query string, and from standard input. Through these three input methods the program can know a lot of information about the type of page that it is supposed to create. When you use Apache Web Server you have the /var/www/cgi-bin/ directory in which you can place and run CGI scripts by default. The scripts can then be seen from a browser on your computer. If a script were placed at /var/www/cgi-bin/script.cgi you could view it by typing the location http://localhost/cgi-bin/script.cgi in the URL location. If you cannot get a script to run you might want to make sure the script has the correct permissions. Change the CGI script to 755:

bash# chmod 755 /var/www/cgi-bin/script.cgi

Unlike the HTML files the CGI files have more restrictions. CGI need to have the execute bit set, but they cannot have the world write bit set. Because of this the numbers 777 and 766 are both invalid. For Perl or other scripting languages they need to be world readable in order to execute. Because of this numbers like 751 and 711 would only work for binary CGI programs. For Perl 755 is probably the best.



Subsections
next up previous contents index
Next: Environment Up: Web Server Previous: Simple HTML   Contents   Index
Joseph Colton 2002-09-24