[Rt-commit] rt branch, 4.0/devel-apache, created. rt-4.0.5-84-g8d97684
Alex Vandiver
alexmv at bestpractical.com
Wed May 23 15:38:55 EDT 2012
The branch, 4.0/devel-apache has been created
at 8d97684f351762078e5c34ed61db14880f9a5004 (commit)
- Log -----------------------------------------------------------------
commit 9e015c66e1bfcbc4ba54e210ee606f0c48092835
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 20:04:44 2012 -0500
Move from a providing a devel static apache.conf to a rt-apache script
This allows for greater flexibility in the configuration, and some
additional cleverness.
diff --git a/devel/tools/apache.conf b/devel/tools/apache.conf
deleted file mode 100644
index 2ae67c6..0000000
--- a/devel/tools/apache.conf
+++ /dev/null
@@ -1,173 +0,0 @@
-# Single-process Apache testing with mod_perl, mod_fcgi, or mod_fastcgi
-#
-# Start this via:
-# apache2 -f `pwd`/devel/tools/apache.conf -DPERL -k start
-#
-# The full path to the configuration file is needed, or Apache assumes
-# it is under the ServerRoot. Since the deployment strategies differ
-# between RT 3 and 4, you must either supply -DRT3 if you are attempting
-# to deploy an rt3 instance. You must also supply one of -DPERL,
-# -DFASTCGI, or -DFCGID.
-#
-# The /opt/rt4/etc/apache_local.conf file should contain:
-# User chmrr
-# Group chmrr
-# Listen 8080
-# ...or the equivilent.
-#
-# Apache access and error logs will be written to /opt/rt4/var/log/.
-#
-<IfDefine !RT3>
-Include /opt/rt4/etc/apache_local.conf
-</IfDefine>
-<IfDefine RT3>
-Include /opt/rt3/etc/apache_local.conf
-</IfDefine>
-
-<IfModule mpm_prefork_module>
- StartServers 1
- MinSpareServers 1
- MaxSpareServers 1
- MaxClients 1
- MaxRequestsPerChild 0
-</IfModule>
-
-<IfModule mpm_worker_module>
- StartServers 1
- MinSpareThreads 1
- MaxSpareThreads 1
- ThreadLimit 1
- ThreadsPerChild 1
- MaxClients 1
- MaxRequestsPerChild 0
-</IfModule>
-
-ServerRoot /etc/apache2
-PidFile /opt/rt4/var/apache2.pid
-LockFile /opt/rt4/var/apache2.lock
-ServerAdmin root at localhost
-
-LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
-LoadModule env_module /usr/lib/apache2/modules/mod_env.so
-LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
-LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
-<IfDefine PERL>
- LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so
-</IfDefine>
-<IfDefine FASTCGI>
- LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
-</IfDefine>
-<IfDefine FCGID>
- LoadModule fcgid_module /usr/lib/apache2/modules/mod_fcgid.so
-</IfDefine>
-
-ErrorLog "/opt/rt4/var/log/apache-error.log"
-TransferLog "/opt/rt4/var/log/apache-access.log"
-LogLevel debug
-
-<Directory />
- Options FollowSymLinks
- AllowOverride None
- Order deny,allow
- Deny from all
-</Directory>
-
-AddDefaultCharset UTF-8
-
-DocumentRoot /var/www
-<Directory /var/www>
- Order allow,deny
- Allow from all
-</Directory>
-
-Alias /NoAuth/images/ /opt/rt4/share/html/NoAuth/images/
-<Directory /opt/rt4/share/html/NoAuth/images>
- Order allow,deny
- Allow from all
-</Directory>
-
-<IfDefine !RT3>
-########## 4.0 mod_perl
-<IfDefine PERL>
- PerlSetEnv RT_SITE_CONFIG /opt/rt4/etc/RT_SiteConfig.pm
- <Location />
- Order allow,deny
- Allow from all
- SetHandler modperl
- PerlResponseHandler Plack::Handler::Apache2
- PerlSetVar psgi_app /opt/rt4/sbin/rt-server
- </Location>
- <Perl>
- use Plack::Handler::Apache2;
- Plack::Handler::Apache2->preload("/opt/rt4/sbin/rt-server");
- </Perl>
-</IfDefine>
-
-########## 4.0 mod_fastcgi
-<IfDefine FASTCGI>
- FastCgiIpcDir /opt/rt4/var
- FastCgiServer /opt/rt4/sbin/rt-server.fcgi -processes 1 -idle-timeout 300
- ScriptAlias / /opt/rt4/sbin/rt-server.fcgi/
- <Location />
- Order allow,deny
- Allow from all
- Options +ExecCGI
- AddHandler fastcgi-script fcgi
- </Location>
-</IfDefine>
-
-########## 4.0 mod_fcgid
-<IfDefine FCGID>
- FcgidProcessTableFile /opt/rt4/var/fcgid_shm
- FcgidIPCDir /opt/rt4/var
- ScriptAlias / /opt/rt4/sbin/rt-server.fcgi/
- <Location />
- Order allow,deny
- Allow from all
- Options +ExecCGI
- AddHandler fcgid-script fcgi
- </Location>
-</IfDefine>
-</IfDefine>
-
-
-<IfDefine RT3>
-########## 3.8 mod_perl
-<IfDefine PERL>
- PerlSetEnv RT_SITE_CONFIG /opt/rt3/etc/RT_SiteConfig.pm
- PerlRequire "/opt/rt3/bin/webmux.pl"
- <Location /NoAuth/images>
- SetHandler default
- </Location>
- <Location />
- SetHandler perl-script
- PerlResponseHandler RT::Mason
- </Location>
-</IfDefine>
-
-########## 3.8 mod_fastcgi
-<IfDefine FASTCGI>
- FastCgiIpcDir /opt/rt3/var
- FastCgiServer /opt/rt3/bin/mason_handler.fcgi -processes 1 -idle-timeout 300
- ScriptAlias / /opt/rt3/bin/mason_handler.fcgi/
- <Location />
- Order allow,deny
- Allow from all
- Options +ExecCGI
- AddHandler fastcgi-script fcgi
- </Location>
-</IfDefine>
-
-########## 3.8 mod_fcgid
-<IfDefine FCGID>
- FcgidProcessTableFile /opt/rt3/var/fcgid_shm
- FcgidIPCDir /opt/rt3/var
- ScriptAlias / /opt/rt3/bin/mason_handler.fcgi/
- <Location />
- Order allow,deny
- Allow from all
- Options +ExecCGI
- AddHandler fcgid-script fcgi
- </Location>
-</IfDefine>
-</IfDefine>
diff --git a/devel/tools/mime.types b/devel/tools/mime.types
new file mode 100644
index 0000000..83ef24d
--- /dev/null
+++ b/devel/tools/mime.types
@@ -0,0 +1,4 @@
+# This is a mime.types for only the file types which we serve
+# statically (those that Apache might care about).
+image/gif gif
+image/png png
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
new file mode 100755
index 0000000..d285c9e
--- /dev/null
+++ b/devel/tools/rt-apache
@@ -0,0 +1,250 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+use FindBin;
+
+my %opt = (
+ root => ($ENV{RTHOME} || "/opt/rt4"),
+
+ fcgid => 0,
+ fastcgi => 0,
+ perl => 0,
+
+ port => 8888,
+
+ modules => "/usr/lib/apache2/modules",
+);
+
+GetOptions( \%opt,
+ "root=s",
+
+ "rt3|3!",
+
+ "fcgid!",
+ "fastcgi!",
+ "perl!",
+
+ "port|p=i",
+
+ "modules=s",
+);
+
+# Determine what module to use
+my $mod;
+if ($opt{fcgid} + $opt{fastcgi} + $opt{perl} > 1) {
+ die "Can only supply one of fcgid, fastcgi, or perl";
+} elsif ($opt{fcgid} + $opt{fastcgi} + $opt{perl} == 0) {
+ my @guess = qw(fcgid fastcgi perl);
+ @guess = grep {-f "$opt{modules}/mod_$_.so"} @guess;
+ die "Neither mod_fcgid, mod_fastcgi, nor mod_perl are installed; aborting"
+ unless @guess;
+ warn "No deployment given -- assuming mod_$guess[0] deployment\n";
+ $mod = $guess[0];
+} else {
+ $mod = (grep {$opt{$_}} qw(fcgid fastcgi perl))[0];
+}
+
+# Detect if we are actually rt3
+if (not -e "$opt{root}/bin/rt-server.fcgi"
+ and -e "$opt{root}/bin/mason_handler.fcgi") {
+ $opt{rt3}++;
+ warn "RT3 install detected!\n";
+}
+
+my $template = join("", <DATA>);
+$template =~ s/\$PORT/$opt{port}/g;
+$template =~ s/\$RTHOME/$opt{root}/g;
+$template =~ s/\$MODULES/$opt{modules}/g;
+$template =~ s/\$TOOLS/$FindBin::Bin/g;
+
+my $conf = "$opt{root}/var/apache.conf";
+open(CONF, ">", $conf)
+ or die "Can't write $conf: $!";
+print CONF $template;
+close CONF;
+
+my @opts = ("-f", $conf, "-D" . uc($mod) );
+push @opts, "-DRT3" if $opt{rt3};
+
+
+# Wait for a previous run to terminate
+if ( open( PIDFILE, "<", "$opt{root}/var/apache2.pid") ) {
+ my $pid = <PIDFILE>;
+ chomp $pid;
+ close PIDFILE;
+ if ($pid and kill 0, $pid) {
+ warn "Waiting for previous run (pid $pid) to finish...\n";
+ sleep 1 while kill 0, $pid;
+ }
+}
+
+# Clean out the log in preparation
+my $log = "$opt{root}/var/log/apache-error.log";
+unlink($log);
+
+# Start 'er up
+warn "Starting apache server on http://localhost:$opt{port}/\n";
+!system("apache2", @opts, "-k", "start")
+ or die "Can't exec apache2: $@";
+# Ignore the return value, as we expect it to be ^C'd
+system("tail", "-f", $log);
+warn "Shutting down apache...\n";
+!system("apache2", @opts, "-k", "stop")
+ or die "Can't exec apache2: $@";
+
+__DATA__
+<IfModule mpm_prefork_module>
+ StartServers 1
+ MinSpareServers 1
+ MaxSpareServers 1
+ MaxClients 1
+ MaxRequestsPerChild 0
+</IfModule>
+
+<IfModule mpm_worker_module>
+ StartServers 1
+ MinSpareThreads 1
+ MaxSpareThreads 1
+ ThreadLimit 1
+ ThreadsPerChild 1
+ MaxClients 1
+ MaxRequestsPerChild 0
+</IfModule>
+
+Listen $PORT
+
+ServerName localhost
+ServerRoot $RTHOME/var
+PidFile $RTHOME/var/apache2.pid
+LockFile $RTHOME/var/apache2.lock
+ServerAdmin root at localhost
+
+LoadModule authz_host_module $MODULES/mod_authz_host.so
+LoadModule env_module $MODULES/mod_env.so
+LoadModule alias_module $MODULES/mod_alias.so
+LoadModule mime_module $MODULES/mod_mime.so
+TypesConfig $TOOLS/mime.types
+
+<IfDefine PERL>
+ LoadModule perl_module $MODULES/mod_perl.so
+</IfDefine>
+<IfDefine FASTCGI>
+ LoadModule fastcgi_module $MODULES/mod_fastcgi.so
+</IfDefine>
+<IfDefine FCGID>
+ LoadModule fcgid_module $MODULES/mod_fcgid.so
+</IfDefine>
+
+ErrorLog "$RTHOME/var/log/apache-error.log"
+TransferLog "$RTHOME/var/log/apache-access.log"
+LogLevel notice
+
+<Directory />
+ Options FollowSymLinks
+ AllowOverride None
+ Order deny,allow
+ Deny from all
+</Directory>
+
+AddDefaultCharset UTF-8
+
+DocumentRoot $RTHOME/share/html
+<Directory $RTHOME/share/html>
+ Order allow,deny
+ Allow from all
+</Directory>
+
+Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
+<Directory $RTHOME/share/html/NoAuth/images>
+ Order allow,deny
+ Allow from all
+</Directory>
+
+<IfDefine !RT3>
+########## 4.0 mod_perl
+<IfDefine PERL>
+ PerlSetEnv RT_SITE_CONFIG $RTHOME/etc/RT_SiteConfig.pm
+ <Location />
+ Order allow,deny
+ Allow from all
+ SetHandler modperl
+ PerlResponseHandler Plack::Handler::Apache2
+ PerlSetVar psgi_app $RTHOME/sbin/rt-server
+ </Location>
+ <Perl>
+ use Plack::Handler::Apache2;
+ Plack::Handler::Apache2->preload("$RTHOME/sbin/rt-server");
+ </Perl>
+</IfDefine>
+
+########## 4.0 mod_fastcgi
+<IfDefine FASTCGI>
+ FastCgiIpcDir $RTHOME/var
+ FastCgiServer $RTHOME/sbin/rt-server.fcgi -processes 1 -idle-timeout 300
+ ScriptAlias / $RTHOME/sbin/rt-server.fcgi/
+ <Location />
+ Order allow,deny
+ Allow from all
+ Options +ExecCGI
+ AddHandler fastcgi-script fcgi
+ </Location>
+</IfDefine>
+
+########## 4.0 mod_fcgid
+<IfDefine FCGID>
+ FcgidProcessTableFile $RTHOME/var/fcgid_shm
+ FcgidIPCDir $RTHOME/var
+ ScriptAlias / $RTHOME/sbin/rt-server.fcgi/
+ <Location />
+ Order allow,deny
+ Allow from all
+ Options +ExecCGI
+ AddHandler fcgid-script fcgi
+ </Location>
+</IfDefine>
+</IfDefine>
+
+
+<IfDefine RT3>
+########## 3.8 mod_perl
+<IfDefine PERL>
+ PerlSetEnv RT_SITE_CONFIG $RTHOME/etc/RT_SiteConfig.pm
+ PerlRequire "$RTHOME/bin/webmux.pl"
+ <Location /NoAuth/images>
+ SetHandler default
+ </Location>
+ <Location />
+ SetHandler perl-script
+ PerlResponseHandler RT::Mason
+ </Location>
+</IfDefine>
+
+########## 3.8 mod_fastcgi
+<IfDefine FASTCGI>
+ FastCgiIpcDir $RTHOME/var
+ FastCgiServer $RTHOME/bin/mason_handler.fcgi -processes 1 -idle-timeout 300
+ ScriptAlias / $RTHOME/bin/mason_handler.fcgi/
+ <Location />
+ Order allow,deny
+ Allow from all
+ Options +ExecCGI
+ AddHandler fastcgi-script fcgi
+ </Location>
+</IfDefine>
+
+########## 3.8 mod_fcgid
+<IfDefine FCGID>
+ FcgidProcessTableFile $RTHOME/var/fcgid_shm
+ FcgidIPCDir $RTHOME/var
+ ScriptAlias / $RTHOME/bin/mason_handler.fcgi/
+ <Location />
+ Order allow,deny
+ Allow from all
+ Options +ExecCGI
+ AddHandler fcgid-script fcgi
+ </Location>
+</IfDefine>
+</IfDefine>
commit 6f8bd79b53044d776e95b51e1273764c109b5489
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 20:07:45 2012 -0500
Add a --ssl option, for https:// serving, and 100-year self-signed certs
diff --git a/devel/tools/localhost.crt b/devel/tools/localhost.crt
new file mode 100644
index 0000000..bc8e572
--- /dev/null
+++ b/devel/tools/localhost.crt
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICpjCCAY4CCQDLtMptx45HuDANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDEwls
+b2NhbGhvc3QwIBcNMTIwMjE3MjIxMTU3WhgPMjExMjAxMjQyMjExNTdaMBQxEjAQ
+BgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
+AKokK5sAKbNkJDoOInDQpwRxDDfanXKUR7MK761G2gWmUpxy+hlUn457VLgDKgDp
+s3gSUk0x3rsXcMxpsSDQ+E37kz5DnbPGSGdiS5tJD6VoQ2NsMfvrY1pZFWNv8wHu
+c4MDtStxsIxvZHjqguWeVUsXLKSfGEMTQ/MbKbn4d/7FSRpQDum2o3AsxHi4VbrS
+aWXRgCfcPlwaoOSc73lCD0kuXIl66wO8DBQOqqBtkuS59BcH+cq1T5wwKzMdJNfp
+Rx0TXISGUa4DSbTjqfAAJe4TzavH73PgNjXBl6+GsGb5/pf8Zad+t62xRcocDfOQ
+5e2ASmInsDtlSX0pfLfBHg0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAUuiDKlBN
+RcR/YYkk/hCgDB4ronO3AO+d264Y3vDK+JsH2lI6/kwxpmJj+bA2IVM+eM5NrcFh
+zEm+LKnyz4EvmxXTI4gI1iFPhOP4NJYmMtyKGavlZP3gNW4JQRYOiA0vQ2Egcngo
+uW2k7xUaNPPkpHptkI0P1jLVl4bX/qKA6tzrmwsmdwNOW9j9zk9BOq8HVvduBDeU
+XFsrdmN4EgD0nU39olaArg/RqMacIfCfKqYdRo9OSbBfQ7x2di9HgI1h2VVfPGi5
+cDRyLlpAY9KNuuStutcFMoQbdwKU/0GFkRuguFPJbIcDg7nhZDXRMU+XugQ8dsZ/
+0VgszAIRc510nA==
+-----END CERTIFICATE-----
diff --git a/devel/tools/localhost.key b/devel/tools/localhost.key
new file mode 100644
index 0000000..4b9dfe2
--- /dev/null
+++ b/devel/tools/localhost.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEAqiQrmwAps2QkOg4icNCnBHEMN9qdcpRHswrvrUbaBaZSnHL6
+GVSfjntUuAMqAOmzeBJSTTHeuxdwzGmxIND4TfuTPkOds8ZIZ2JLm0kPpWhDY2wx
+++tjWlkVY2/zAe5zgwO1K3GwjG9keOqC5Z5VSxcspJ8YQxND8xspufh3/sVJGlAO
+6bajcCzEeLhVutJpZdGAJ9w+XBqg5JzveUIPSS5ciXrrA7wMFA6qoG2S5Ln0Fwf5
+yrVPnDArMx0k1+lHHRNchIZRrgNJtOOp8AAl7hPNq8fvc+A2NcGXr4awZvn+l/xl
+p363rbFFyhwN85Dl7YBKYiewO2VJfSl8t8EeDQIDAQABAoIBAGeZsrulM786QRzg
+snQDeU+pDomMIsc8JxSMmjjmpac/CZqeIFAASU/XJVUPCCqaI1//uAGtVjSSJ2sx
+CFw1Ip1JjPUi8woeuMPLBMK/kDll7XLC1QTS5iKDkBSGfHA2pDuorE6R4bEBuyot
+khsDeGhK6jIrdfiR6JRFe/jzpQ2KUV7PDKhcGjWdCCGoss7s2d0Gx4UdlYn456Dr
+atPLXU9Aspg7uIUSO44Zwal03k25S0EW4WjdFCx3+1WqXs8l+XNXlqowZSL8qjOy
+cL2H5bpElE+NjSsHtTZdzC8jcDhbIRp8cZD32t+BRY5gqodKw+Z3MmblL2b3/qPi
+xNMaq8ECgYEA3ACjPUhRb7kYMgmowOXR/HL9Aht+4uCM+UM/pz0S4rn4MooBuCwv
+Nc0oFi5wFNJpFsOsiJwik7re1/olPPneZWgZWgBoiQl4+OB5hzvLc56B9Ez3Z84X
+19BxKcUaf5gXjxVAAAeKxn8ZbL/OHB3WvYP4zsIO1J+ijOe2LZJFEpUCgYEAxfr4
+RsK8avAdgOC0e/uB007rtiErCIaVnK/1WMPwWb5FxDkkl31MTB6oLO/JU5zfCsE1
+ROtnehB69c73sokWzAqMCuVFs+M0Owq1Kdm63b1k0wtUZL7v3wfGoUgZFL/65LDg
+RQ2Grntul5H7XS9c9v7Tn9GSo8VIbej6fvPPN5kCgYAqbL0N7ko1/z2ZOJ+gQzFR
+O2Nq6p53ZdIJp1w5BeAEdNRV+qMGPw8DkwJt9JqMiV7WkvlMhr9sOZcLkyNnNNAc
+QgzRfE6sTnVTmQYWfANp0mFBGS6EiAu1BG8uHOJVRKEWaISk/M9YI95lSD+Y0HA+
+r5plVKrDed1AytYox5ImWQKBgC/VNQsTnaZQoTA0GiciWvmMxdJZLSaALcGPmb16
+iaWFHSINlFOtiDOT7Jn+zSuQaSsWByLBpVyOgsbE3H+cM4/UtIUlY7PUnxfsvFyC
+KG3Ohn+e6yL0JsxB+rGY08Z5o8qBGY5VeEbLt6qTMKIRAWsDommonr9GuPslIPBv
+Q49xAoGAI7LBHEJtPTJx56EcKicST++NzUYha7E8nkqogs9oTTpdT6n+viHDCNud
+YUUK2slnEvgOPtNEkf1kHTqcajKZmIVpQi1cZqKzPCgk49JM+2OU+98qFR8UKe8i
+s5t09zDVhy9Hy+MaASqbU1AQT9bWbyfsgormjQ5jzadDdP5zovE=
+-----END RSA PRIVATE KEY-----
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
index d285c9e..70e74e4 100755
--- a/devel/tools/rt-apache
+++ b/devel/tools/rt-apache
@@ -28,6 +28,7 @@ GetOptions( \%opt,
"perl!",
"port|p=i",
+ "ssl:i",
"modules=s",
);
@@ -54,8 +55,12 @@ if (not -e "$opt{root}/bin/rt-server.fcgi"
warn "RT3 install detected!\n";
}
+# Set ssl port if they want it but didn't provide a number
+$opt{ssl} = 4430 if defined $opt{ssl} and not $opt{ssl};
+
my $template = join("", <DATA>);
$template =~ s/\$PORT/$opt{port}/g;
+$template =~ s/\$SSL/$opt{ssl} || 0/ge;
$template =~ s/\$RTHOME/$opt{root}/g;
$template =~ s/\$MODULES/$opt{modules}/g;
$template =~ s/\$TOOLS/$FindBin::Bin/g;
@@ -67,6 +72,7 @@ print CONF $template;
close CONF;
my @opts = ("-f", $conf, "-D" . uc($mod) );
+push @opts, "-DSSL" if $opt{ssl};
push @opts, "-DRT3" if $opt{rt3};
@@ -86,7 +92,8 @@ my $log = "$opt{root}/var/log/apache-error.log";
unlink($log);
# Start 'er up
-warn "Starting apache server on http://localhost:$opt{port}/\n";
+warn "Starting apache server on http://localhost:$opt{port}/"
+ . ($opt{ssl} ? " and https://localhost:$opt{ssl}/" : "") . "\n";
!system("apache2", @opts, "-k", "start")
or die "Can't exec apache2: $@";
# Ignore the return value, as we expect it to be ^C'd
@@ -115,6 +122,9 @@ __DATA__
</IfModule>
Listen $PORT
+<IfDefine SSL>
+ Listen $SSL
+</IfDefine>
ServerName localhost
ServerRoot $RTHOME/var
@@ -137,6 +147,9 @@ TypesConfig $TOOLS/mime.types
<IfDefine FCGID>
LoadModule fcgid_module $MODULES/mod_fcgid.so
</IfDefine>
+<IfDefine SSL>
+ LoadModule ssl_module $MODULES/mod_ssl.so
+</IfDefine>
ErrorLog "$RTHOME/var/log/apache-error.log"
TransferLog "$RTHOME/var/log/apache-access.log"
@@ -248,3 +261,17 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
</Location>
</IfDefine>
</IfDefine>
+
+<IfDefine SSL>
+ SSLRandomSeed startup builtin
+ SSLRandomSeed startup file:/dev/urandom 512
+ SSLRandomSeed connect builtin
+ SSLRandomSeed connect file:/dev/urandom 512
+ SSLSessionCache shmcb:$RTHOME/var/ssl_scache(512000)
+ SSLMutex file:$RTHOME/var/ssl_mutex
+ <VirtualHost *:$SSL>
+ SSLEngine on
+ SSLCertificateFile $TOOLS/localhost.crt
+ SSLCertificateKeyFile $TOOLS/localhost.key
+ </VirtualHost>
+</IfDefine>
commit b3da738bd9fc1527cfdb360eec1bae9aea1ae5d2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 20:18:21 2012 -0500
Parse WebPort from RT_SiteConfig.pm
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
index 70e74e4..5f3f04c 100755
--- a/devel/tools/rt-apache
+++ b/devel/tools/rt-apache
@@ -13,8 +13,6 @@ my %opt = (
fastcgi => 0,
perl => 0,
- port => 8888,
-
modules => "/usr/lib/apache2/modules",
);
@@ -55,6 +53,20 @@ if (not -e "$opt{root}/bin/rt-server.fcgi"
warn "RT3 install detected!\n";
}
+# Parse etc/RT_SiteConfig.pm for the default port
+if ( $opt{port} ) {
+ # We're set
+} elsif ( open(CONF, "<", "$opt{root}/etc/RT_SiteConfig.pm") ) {
+ # We're going to be evil, and try to parse the config
+ my $conf = join("", <CONF>);
+ $opt{port} = $1
+ if $conf =~ /^\s*Set\(\s*\$WebPort\s*(?:,|=>)\s*['"]?(\d+)['"]?\s*\)/m;
+} else {
+ warn "Can't open $opt{root}/etc/RT_SiteConfig.pm: $!\n";
+ warn "Defaulting to port 8888\n";
+ $opt{port} = 8888;
+}
+
# Set ssl port if they want it but didn't provide a number
$opt{ssl} = 4430 if defined $opt{ssl} and not $opt{ssl};
commit 7248ca7aa93a7b2d41ac217321317186353d0ec2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 20:26:35 2012 -0500
Factor out config parsing
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
index 5f3f04c..4a5a42a 100755
--- a/devel/tools/rt-apache
+++ b/devel/tools/rt-apache
@@ -54,15 +54,9 @@ if (not -e "$opt{root}/bin/rt-server.fcgi"
}
# Parse etc/RT_SiteConfig.pm for the default port
-if ( $opt{port} ) {
- # We're set
-} elsif ( open(CONF, "<", "$opt{root}/etc/RT_SiteConfig.pm") ) {
- # We're going to be evil, and try to parse the config
- my $conf = join("", <CONF>);
- $opt{port} = $1
- if $conf =~ /^\s*Set\(\s*\$WebPort\s*(?:,|=>)\s*['"]?(\d+)['"]?\s*\)/m;
-} else {
- warn "Can't open $opt{root}/etc/RT_SiteConfig.pm: $!\n";
+my $RTCONF;
+$opt{port} ||= parseconf( "WebPort" );
+unless ($opt{port}) {
warn "Defaulting to port 8888\n";
$opt{port} = 8888;
}
@@ -114,6 +108,24 @@ warn "Shutting down apache...\n";
!system("apache2", @opts, "-k", "stop")
or die "Can't exec apache2: $@";
+
+sub parseconf {
+ my ($optname) = @_;
+ # We're going to be evil, and try to parse the config
+ unless (defined $RTCONF) {
+ unless ( open(CONF, "<", "$opt{root}/etc/RT_SiteConfig.pm") ) {
+ warn "Can't open $opt{root}/etc/RT_SiteConfig.pm: $!\n";
+ $RTCONF = "";
+ return;
+ }
+ $RTCONF = join("", <CONF>);
+ close CONF;
+ }
+
+ return unless $RTCONF =~ /^\s*Set\(\s*\$$optname\s*(?:,|=>)\s*['"]?(.*?)['"]?\s*\)/m;
+ return $1;
+}
+
__DATA__
<IfModule mpm_prefork_module>
StartServers 1
commit 57532c93394a145642e93d359e3013a476867366
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 21:09:15 2012 -0500
Support non-empty WebPaths
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
index 4a5a42a..7b4ac38 100755
--- a/devel/tools/rt-apache
+++ b/devel/tools/rt-apache
@@ -64,8 +64,13 @@ unless ($opt{port}) {
# Set ssl port if they want it but didn't provide a number
$opt{ssl} = 4430 if defined $opt{ssl} and not $opt{ssl};
+# Parse out the WebPath
+my $path = parseconf( "WebPath" ) || "";
+
my $template = join("", <DATA>);
$template =~ s/\$PORT/$opt{port}/g;
+$template =~ s!\$PATH/!$path/!g;
+$template =~ s!\$PATH!$path || "/"!ge;
$template =~ s/\$SSL/$opt{ssl} || 0/ge;
$template =~ s/\$RTHOME/$opt{root}/g;
$template =~ s/\$MODULES/$opt{modules}/g;
@@ -98,8 +103,8 @@ my $log = "$opt{root}/var/log/apache-error.log";
unlink($log);
# Start 'er up
-warn "Starting apache server on http://localhost:$opt{port}/"
- . ($opt{ssl} ? " and https://localhost:$opt{ssl}/" : "") . "\n";
+warn "Starting apache server on http://localhost:$opt{port}$path/"
+ . ($opt{ssl} ? " and https://localhost:$opt{ssl}$path/" : "") . "\n";
!system("apache2", @opts, "-k", "start")
or die "Can't exec apache2: $@";
# Ignore the return value, as we expect it to be ^C'd
@@ -194,7 +199,7 @@ DocumentRoot $RTHOME/share/html
Allow from all
</Directory>
-Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
+Alias $PATH/NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<Directory $RTHOME/share/html/NoAuth/images>
Order allow,deny
Allow from all
@@ -204,7 +209,7 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
########## 4.0 mod_perl
<IfDefine PERL>
PerlSetEnv RT_SITE_CONFIG $RTHOME/etc/RT_SiteConfig.pm
- <Location />
+ <Location $PATH>
Order allow,deny
Allow from all
SetHandler modperl
@@ -221,8 +226,8 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<IfDefine FASTCGI>
FastCgiIpcDir $RTHOME/var
FastCgiServer $RTHOME/sbin/rt-server.fcgi -processes 1 -idle-timeout 300
- ScriptAlias / $RTHOME/sbin/rt-server.fcgi/
- <Location />
+ ScriptAlias $PATH $RTHOME/sbin/rt-server.fcgi/
+ <Location $PATH>
Order allow,deny
Allow from all
Options +ExecCGI
@@ -234,8 +239,8 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<IfDefine FCGID>
FcgidProcessTableFile $RTHOME/var/fcgid_shm
FcgidIPCDir $RTHOME/var
- ScriptAlias / $RTHOME/sbin/rt-server.fcgi/
- <Location />
+ ScriptAlias $PATH $RTHOME/sbin/rt-server.fcgi/
+ <Location $PATH>
Order allow,deny
Allow from all
Options +ExecCGI
@@ -250,10 +255,10 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<IfDefine PERL>
PerlSetEnv RT_SITE_CONFIG $RTHOME/etc/RT_SiteConfig.pm
PerlRequire "$RTHOME/bin/webmux.pl"
- <Location /NoAuth/images>
+ <Location $PATH/NoAuth/images>
SetHandler default
</Location>
- <Location />
+ <Location $PATH>
SetHandler perl-script
PerlResponseHandler RT::Mason
</Location>
@@ -263,8 +268,8 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<IfDefine FASTCGI>
FastCgiIpcDir $RTHOME/var
FastCgiServer $RTHOME/bin/mason_handler.fcgi -processes 1 -idle-timeout 300
- ScriptAlias / $RTHOME/bin/mason_handler.fcgi/
- <Location />
+ ScriptAlias $PATH $RTHOME/bin/mason_handler.fcgi/
+ <Location $PATH>
Order allow,deny
Allow from all
Options +ExecCGI
@@ -276,8 +281,8 @@ Alias /NoAuth/images/ $RTHOME/share/html/NoAuth/images/
<IfDefine FCGID>
FcgidProcessTableFile $RTHOME/var/fcgid_shm
FcgidIPCDir $RTHOME/var
- ScriptAlias / $RTHOME/bin/mason_handler.fcgi/
- <Location />
+ ScriptAlias $PATH $RTHOME/bin/mason_handler.fcgi/
+ <Location $PATH>
Order allow,deny
Allow from all
Options +ExecCGI
commit 8d97684f351762078e5c34ed61db14880f9a5004
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Feb 17 21:39:55 2012 -0500
Add documentation
diff --git a/devel/tools/rt-apache b/devel/tools/rt-apache
index 7b4ac38..1c530e8 100755
--- a/devel/tools/rt-apache
+++ b/devel/tools/rt-apache
@@ -5,6 +5,7 @@ use warnings;
use Getopt::Long;
use FindBin;
+use Pod::Usage;
my %opt = (
root => ($ENV{RTHOME} || "/opt/rt4"),
@@ -29,16 +30,19 @@ GetOptions( \%opt,
"ssl:i",
"modules=s",
-);
+
+ "help|h|?",
+) or pod2usage( 1 );
+pod2usage( {verbose => 2} ) if $opt{help};
# Determine what module to use
my $mod;
if ($opt{fcgid} + $opt{fastcgi} + $opt{perl} > 1) {
- die "Can only supply one of fcgid, fastcgi, or perl";
+ die "Can only supply one of fcgid, fastcgi, or perl\n";
} elsif ($opt{fcgid} + $opt{fastcgi} + $opt{perl} == 0) {
my @guess = qw(fcgid fastcgi perl);
@guess = grep {-f "$opt{modules}/mod_$_.so"} @guess;
- die "Neither mod_fcgid, mod_fastcgi, nor mod_perl are installed; aborting"
+ die "Neither mod_fcgid, mod_fastcgi, nor mod_perl are installed; aborting\n"
unless @guess;
warn "No deployment given -- assuming mod_$guess[0] deployment\n";
$mod = $guess[0];
@@ -46,6 +50,10 @@ if ($opt{fcgid} + $opt{fastcgi} + $opt{perl} > 1) {
$mod = (grep {$opt{$_}} qw(fcgid fastcgi perl))[0];
}
+# Sanity check that the root contains an RT install
+die "$opt{root} doesn't look like an RT install\n"
+ unless -e "$opt{root}/lib/RT.pm";
+
# Detect if we are actually rt3
if (not -e "$opt{root}/bin/rt-server.fcgi"
and -e "$opt{root}/bin/mason_handler.fcgi") {
@@ -131,6 +139,66 @@ sub parseconf {
return $1;
}
+=head1 NAME
+
+rt-apache - Wrapper to start single-threaded Apache running RT
+
+=head1 DESCRIPTION
+
+This script exists to make it easier to run RT under Apache for testing.
+It is not intended as a way to deploy RT, or to provide example Apache
+configuration for RT. For instructions on how to deploy RT with Apache,
+please read the provided F<docs/web_deployment.pod> file.
+
+Running this script will start F<apache2> with a custom-built
+configuration file, built based on command-line options and the contents
+of your F<RT_SiteConfig.pm>. It will work with either RT 3.8.x or RT
+4.0.x. As it is primarily for simple testing, it only starts one Apache
+process or thread, and runs as the current user.
+
+=head1 OPTIONS
+
+C<rt-apache> will parse your F<RT_SiteConfig.pm> for its C<WebPath> and
+C<WebPort> configuration, and adjust its defaults accordingly.
+
+=over
+
+=item --root B<path>
+
+The path to the RT install to serve. This defaults to the C<RTHOME>
+environment variable, or C</opt/rt4>.
+
+=item --fcgid, --fastcgi, --perl
+
+Determines the Apache module which is used. By default, the first one
+of that list which exists will be used. See also L</--modules>.
+
+=item --port B<number>
+
+Choses the port to listen on. By default, this is parsed from the
+F<RT_SiteConfig.pm>, and falling back to 8888.
+
+=item --ssl [B<number>]
+
+Also listens on the provided port with HTTPS, using a self-signed
+certificate for C<localhost>. If the port number is not specified,
+defaults to port 4430.
+
+=item --rt3, -3
+
+Declares that the RT install in question is RT 3.8.x. C<rt-apache> can
+usually detect this for you, however.
+
+=item --modules B<path>
+
+The path to the Apache2 modules directory, which is expected to contain
+one of F<mod_fcgid.so>, F<mod_fastcgi.so>, or F<mod_perl.so>. Defaults
+to F</usr/lib/apache2/modules>.
+
+=back
+
+=cut
+
__DATA__
<IfModule mpm_prefork_module>
StartServers 1
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list