> Date: Sat, 13 Aug 2005 19:42:53 -0400 > From: Tom Metro > To: L-boston-pm > Subject: [Boston.pm] file layout and installing CGI applications > > I'm looking to package a CGI application for installation by others and > want to minimize the amount of web server reconfiguration required by > the admin. The target platform is Linux or another UNIX-like OS and Apache.
... > Years ago there was cgi-bin and everyone piled their scripts in that one > directory, or at best made a subdirectory from it. Thankfully that > ugliness is behind us. Though now it is less clear what the most popular > conventions are for installing plain old CGI applications on modern > systems. I'd be curious to hear what other people are doing to address > this and tricks for minimizing the dependencies. In the java world, you have Sun's servlet specification, that describes how a web application interacts with the servlet container that runs it. http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html While it's not apache/cgi, some of the general ideas could be applied to a cgi-app. The basic idea - you set up a mapping between a base URI and the physical directory that contains the application. The spec defines a certain amount of structure to the application root directory (eg - the root directory contains a 'WEB-INF' sub directory which holds the application's libraries and configuration files, and the servlet container cannot allow a http client to access these files directly). If you look at the spec above, pages 68-78 describe the directory layout. In the apache world, this isn't much different than Alias "/myapp/" /path/to/myapp/public_html/ <Directory "/path/to/myapp/public_html/"> Allow from all Options +ExecCGI # other options as necessary </Directory> As long as `myapp' knows its own directory structure and uses relative URIs, this arrangement will work just fine. If you need access to other libraries, define PERL5LIB in the apache configuration, or do something like this at the beginning of your CGI scripts BEGIN { use File::Basename; use File::Spec; my $webroot = File::Basename::dirname($ENV{'SCRIPT_FILENAME'}); my $approot = File::Basename::dirname($webroot); my $libdir = File::Spec->catdir($approot, "lib"); unshift(@INC, $libdir); } Server-side environment variables can be a big help too. If you give the end user a set of boilerplate configuration directives, that should be enough to get them going. > Personally I lean towards the Dan Bernstein-ish > (http://cr.yp.to/slashpackage.html) approach to application > installation > where all the app's files are kept together in one subdirectory, and > then symlinks (or Apache aliases) are used to point to them. Sounds interesting. Unfortunately Dan's web site doesn't seem to be responding right now. I'll have to read it later. Steve _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

