Gerald Richter wrote:
Is mod_perl staticly compiled into Apache or loaded as module?

I think I am building it statically into Apache. I wrote a script to help 
automate the process:

#!/bin/sh

# First time:

# 1. Unpack mod_security-1.x.x.tar.gz into /usr/src
# 2. Rename dir as mod_security
# 3. Unpack mod_perl into /usr/src
# 4. Rename dir as mod_perl

# Building httpd_perl:

# 1. Unpack apache tarball into /usr/src
# 2. Rename unpacked dir to httpd_perl
# 3. Run this script

cp /usr/src/mod_security/apache1/mod_security.c 
/usr/src/httpd_perl/src/modules/extra \
&& cd /usr/src/mod_perl
make clean
perl Makefile.PL \
     APACHE_SRC=../httpd_perl/src \
     DO_HTTPD=1 \
     USE_APACI=1 \
     EVERYTHING=1 \
     APACHE_PREFIX=/usr/local/httpd_perl \
     APACI_ARGS='--prefix=/usr/local/httpd_perl \
                 --target=httpd_perl \
                 --disable-rule=EXPAT \
                 --enable-module=mime_magic \
                 --enable-module=status \
                 --enable-module=info \
                 --enable-module=rewrite \
                 --enable-module=expires \
                 --enable-module=headers \
                 --activate-module=src/modules/extra/mod_security \
                 --enable-module=security \
                 --enable-module=so' \
&& make \
&& make test \
&& make install \
&& /bin/rm -f /usr/local/httpd_perl/cgi-bin/*
/www/bin/apachectl_perl stop
sleep 10
&& /www/bin/apachectl_perl start


There is another script which builds the front end webserver, which has the lightweight proxy modules and not much else. The httpd_proxy is not relevant to this, I think, because all we are doing is trying to start httpd_perl.

I wrote this script a while back, and I'm a little embarrassed to admit that now you mention it, I'm actually really not sure if this is building mod_perl as a module or statically. Does this script tell us which?

I didn't answer about the thread question, because I didn't ever saw this,
Embperl itself doesn't uses threads and I don't use Debian, so there simply
nothing I can tell about this, beside the fact that some code seems to start
a thread which isn't finished when the Perl interpreter ends.

I'm hoping that a successful move to Embperl 2.0 might make it go away. In any case, it would be good to make the move since 2.0 is the one you want to be working on, and if I have bugs then it is really that one which will be useful to you to fix.

In the interests of completeness, here's the startup.pl script:

#!/usr/bin/perl

# First modify the include path
BEGIN
{
    use Apache ();
    use lib '/www/lib/perl';
}

# Common modules
use Apache::Constants ();
use Apache::File ();
use Apache::Log ();
use IO::Zlib ();
use Safe ();
use URI::Escape ();
use Log::Logger ();
use File::Copy ();
use File::Path ();
use File::Glob ();
use Time::Zone ();
use CGI qw (-compile :cookie cgi_error header);
use Date::Calc qw(:all);
use Image::Magick ();
use MIME::Base64 ();
use URI ();
use HTML::Tagset ();
use HTML::Parser ();
use Digest::MD5 ();
use HTML::TokeParser ();
use HTML::Embperl ();
use HTML::EmbperlObject ();
use Embperl ();
use Embperl::Object ();
use Mail::Sender;
use LWP::UserAgent;
use HTTP::Request;
use DBI ();
DBI->install_driver('mysql');
use Digest::HMAC_MD5 qw(hmac_md5_hex);
use Crypt::CBC;
use Crypt::Blowfish;
use Crypt::OpenSSL::Random;
use Crypt::OpenSSL::RSA;
use SOAP::Lite ();
use Text::Wrap;
use POSIX;
use MyHTMLFilters;
use Lingua::Ispell;
use Math::BaseCalc;

# My modules
use Apache::BlockAgent ();
use Apache::Nilspace::Main::Access ();
use Apache::Nilspace::Subscription::Access ();
use Apache::Nilspace::Subscription::Handler ();
use Nilspace ();
use Nilspace::Agenda ();
use Nilspace::Commerce ();
use Nilspace::Mail ();

# Apache::VMonitor
use Apache::VMonitor();
$Apache::VMonitor::Config{BLINKING} = 1;
$Apache::VMonitor::Config{REFRESH}  = 0;
$Apache::VMonitor::Config{VERBOSE}  = 0;
$Apache::VMonitor::Config{SYSTEM}   = 1;
$Apache::VMonitor::Config{APACHE}   = 1;
$Apache::VMonitor::Config{PROCS}    = 1;
$Apache::VMonitor::Config{MOUNT}    = 1;
$Apache::VMonitor::Config{FS_USAGE} = 1;
$Apache::VMonitor::Config{SORT_BY}  = 'size';
$Apache::VMonitor::PROC_REGEX = join "\|", qw(httpd_perl httpd_proxy mysql);

# For remote IP address
sub My::ProxyRemoteAddr ($)
{
    my $r = shift;

    # we'll only look at the X-Forwarded-For header if the requests
    # comes from our proxy at localhost
    return Apache::Constants::OK
        unless ($r->connection->remote_ip eq "127.0.0.1")
        and $r->header_in('X-Forwarded-For');

    # Select last value in the chain -- original client's ip
    if (my ($ip) = $r->headers_in->{'X-Forwarded-For'} =~ /([^,\s]+)$/)
    {
        $r->connection->remote_ip($ip);
    }

    return Apache::Constants::OK;
}

# Preload Embperl website code
if (lc($ENV{PRELOAD_WEBSITES}) eq 'on')
{
    preload_dir ('/www/lib/perl/Apache', '*.html *.epl');
    preload_dir ('/www/vhosts/www.neilgunton.com/htdocs', '*.html *.epl');
    preload_dir ('/www/contact', '*.html *.epl');
    preload_dir ('/www/vhosts/www.crazyguyonabike.com/htdocs', '*.html *.epl');
    #preload_dir ('/www/vhosts/www.onlineidregistry.com/htdocs', '*.html 
*.epl');
}

# Recursive directory traversal sub which preloads Embperl files
sub preload_dir
{
    my ($dir,            # The current directory which is to be processed
        $pattern,        # A pattern identifying files to be processed, e.g. 
'*.html *.epl'
        @search_path     # List of paths for giving to Embperl to search for 
files
        ) = @_;

    @search_path = () if [EMAIL PROTECTED];

    # Put the current dir on the search path
    push (@search_path, $dir);

    local *DIR;
    opendir (DIR, $dir) or die "Could not open directory: $dir: $!";

    # First, process files in this directory
    # Pattern consists of a potential list of patterns, separated by spaces.
    # First we make a list of patterns, and then glob each of these
    foreach my $glob (split (/\s/, $pattern))
    {
        # Iterate through the resulting list of files
        foreach my $file (File::Glob::glob ("$dir/$glob"))
        {
            if (!(-d $file) && (-e $file))
            {
                my $path = '';
                foreach my $i (1 .. scalar(@search_path))
                {
                    $path .= ':' if $path ne '';
                    $path .= $search_path[scalar(@search_path) - $i] . '/';
                }
                $path .= ':/www/lib/perl/Apache/';
                $path .= ':' . join(':', @INC);
                $file =~ /\/([^\/]+)$/;
                my $filename = $1;
                print "\nEmbperl::Execute $file\n";
                #HTML::Embperl::Execute ({inputfile => $filename,
                #                        import => 0,
                #                        path => $path,
                #                        escmode => 0,
                #                        options => 16}) ;
                print "\tfilename = $filename\n\tpath = $path\n";
                Embperl::Execute ({inputfile => $filename,
                                   import => 0,
                                   path => $path,
                                   escmode => 0,
                                   options => 16,
                                   recipe => 'Embperl'
                                  }) ;
            }
        }
    }

    # Now, recursively go down into subdirectories
    while (defined(my $subdir = readdir (DIR)))
    {
        # Only recurse on directories, which do not start with ".", and skip 
symbolic links
        if (-d "$dir/$subdir" &&
            !(-l "$dir/$subdir") &&
            ($subdir !~ /^\.{1,2}$/))
        {

            preload_dir ("$dir/$subdir", $pattern, @search_path);
        }
    }
}

1;

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to