If you want to execute a cgi or any other script from your website, you can put the
executable file in your cgi-bin directory: /htdocs/www/cgi-bin/
CGI and other scripts are not required to go in the cgi-bin directory. You can execute them
from your website in any directory you choose, as long as it is under the website DocumentRoot.
After you put the executable script or program somewhere accessible to a browser on your
website, then make sure it is world executeable but not world writeable. The shell command
to set the correct permissions on the file is:
chmod 755 /htdocs/www/cgi-bin/cgi-scriptname
Some FTP programs have a graphical way of setting permissions too.
Regardless of what any instructions that come with your cgi script say, no script needs to
be world writeable or be in a world writeable directory. All your cgi scripts execute with
your own permissions. Therefore, if you can write to a directory or file, then so can your
script. They will not run if you make them world writable.
Setting permissions chmod 755 will always work for all directories and all cgi scripts.
Regular files that are not scripts should be chmod 644.
To execute your script from a webpage, you can either go to the script directly in a browser or make it the “action” of an html form like