Where to Put CGI Program


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 the most common used NCSA httpd server, There are two methods for controlling access to directories:

So Now we can see that there's two ways to place your CGI programs:
  1. Ask your web master to put your CGI scripts in the server's cgi-bin or other directory with CGI execuation permission.
  2. 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):
  3.  
    AddType application/x-httpd-cgi .cgi
    This tells the server that all files have the .cgi extension are CGI programs. Of course you need to change all your CGI programs with .cgi extension. But anyway, before start writting your own CGI program, come to see your web master first!
    Previous PageTable of ContentNext Page