[tpm] Splitting a perl cgi into cgi-bin and htdocs

Indy Singh indy at indigostar.com
Sat Oct 25 08:36:58 PDT 2008


Hi Folks,

I am working on a perl cgi application and I'm wondering if it would be 
better to split it into two directories in cgi-bin and htdocs, or put 
all the parts into one directory under htdocs.

Background:
The perl cgi application consists of components like the following:
1) The main cgi script
2) Supporting perl scripts meant to run from a shell
3) Perl modules used by the scripts
4) Data files used by the cgi (e.g. templates)
and
5) Data files that must be in the htdocs directory (like images)
6) Html documentation

The files in the second group have to go in the htdocs directory, but I 
am wondering if I can simplify the directory structure by putting all 
the files from the first group in the htdocs directory.  One of the 
advantages of having a single directory structure is that installation 
would be simplified, one would just untar a single file into one 
directory.  Another advantage is that my Apache is already configured to 
use mod_perl to process .cgi and .pl file if they are in the htdocs or 
below.

Anybody have experience with this?

Other questions that come to mind for the single directory scenario are:
* How to configure .htaccess to run the cgi script by default?
* How to prevent the perl shell scripts from being accessed?
* How to prevent the perl modules (.pm files) from being accessed?
Would be better to put the restricted files into a subdirectory and 
configure .htaccess file to deny access?

Indy Singh
IndigoSTAR Software -- www.indigostar.com



More information about the toronto-pm mailing list