Currently, if your local httpd.conf doesn't contain a ServerRoot directive but has relative-paths to things like DSO modules, Apache::Test fails. Obviously, a ServerRoot is necessary for Apache to function properly, but the ServerRoot directive is only one of several ways to set it.

Once nice trick for making a config file that will run on several versions of Apache (or even different server architectures) is to make all architecture-specific paths (mainly to DSO modules) relative to ServerRoot, while generic, architecture-agnositic paths are absolute. You then rely on the path compiled into httpd (via the "--prefix" configuration option) to find your DSOs.

The easiest way I've found to do this in Apache::Test is attached. It extracts the "PREFIX" from apxs and uses that as the default inherited ServerRoot value. If a value is hard-coded into the global httpd.conf, it supercedes the apxs value and everything works just like before.

The patch is against 1.05 and I tested it with Apache 1.3.29 and 1.3.28.

--
Mike Cramer
http://www.webkist.com/ | AIM: MikeWebkist
diff --recursive -buB Apache-Test-1.05/lib/Apache/TestConfigParse.pm 
Apache-Test-1.05-mrc/lib/Apache/TestConfigParse.pm
--- Apache-Test-1.05/lib/Apache/TestConfigParse.pm      2003-10-07 
09:41:13.000000000 -0400
+++ Apache-Test-1.05-mrc/lib/Apache/TestConfigParse.pm  2003-10-31 
12:01:21.000000000 -0500
@@ -246,7 +246,7 @@
     #initialize array refs and such
     while (my($spec, $wanted) = each %wanted_config) {
         for my $directive (keys %$wanted) {
-            $spec_init{$spec}->($c, $directive);
+            $spec_init{$spec}->($c, $directive) unless $c->{$directive};
         }
     }
 
diff --recursive -buB Apache-Test-1.05/lib/Apache/TestConfig.pm 
Apache-Test-1.05-mrc/lib/Apache/TestConfig.pm
--- Apache-Test-1.05/lib/Apache/TestConfig.pm   2003-10-22 10:39:14.000000000 
-0400
+++ Apache-Test-1.05-mrc/lib/Apache/TestConfig.pm       2003-10-31 
12:05:44.000000000 -0500
@@ -292,6 +292,7 @@
     $vars->{sbindir}  ||= $self->apxs('SBINDIR');
     $vars->{target}   ||= $self->apxs('TARGET');
     $vars->{conf_dir} ||= $self->apxs('SYSCONFDIR');
+    $self->{inherit_config}->{ServerRoot} ||= $self->apxs('PREFIX');
 
     if ($vars->{conf_dir}) {
         $vars->{httpd_conf} ||= catfile $vars->{conf_dir}, 'httpd.conf';

Reply via email to