You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Faust <CF...@doyougot.com> on 2003/03/18 19:39:41 UTC

Using a Startup.pl

Hello All,

This may be a stupid question, but I'm not finding any clear documentation
to give me a answer.

I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm using NamedBased
Virtual Hosting in apache (so I have a number of virtual hosts and apache
directs properly based on hostname).

I use a startup.pl to load up common things like DBI, CGI, HTML::Template
etc..

Should I have just a single startup.pl and will that work with all virtual
hosts? Or should I have a startup.pl per virtual host.

Currently I'm using a startup.pl per virtual host and I'm seeing some
strange problems, I'm wondering if my problem is there should only be one
startup.pl - or does it not matter either way?

Thanks
-Chris



Re: Using a Startup.pl

Posted by Stas Bekman <st...@stason.org>.
Chris Faust wrote:

> I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm using NamedBased
> Virtual Hosting in apache (so I have a number of virtual hosts and apache
> directs properly based on hostname).

also make sure to upgrade your mod_perl 2 to the latest stable version 1.99_08 
or even better the cvs one. The one coming with RH is too old. Save yourself 
troubles.
http://perl.apache.org/download/index.html

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Using a Startup.pl

Posted by Stas Bekman <st...@stason.org>.
Chris Faust wrote:
> Thanks for the explanation and the details Stas,
> 
> I'm actually OK with everything in my startup.pl being available to all
> virtual hosts.
> After reading the post from Thomas I went back in and removed all the
> "perlModule" and "perlRequire" lines from the virtual host containers and
> loaded everything at once outside of the VHosts and it seems to have
> corrected my problems. Its good to know if there is a need to divide it the
> ability is there to do so (looks like I was doing it but without creating a
> new parent interpreter).

Yes, diving should also save memory, assuming that different VHosts have 
different big code bases.

> I am using mod_perl 1.99.08, this is my second dev server and I've found
> that RH is OK as a OS but I've had MUCH better results leaving it at that
> and installing Apache, mod_perl and mySql etc. from source and not as part
> of the RH install or using RPMs..

I didn't say that either RH or its packages aren't good. I just said that one 
should upgrade to the latest mod_perl, since older versions have more bugs and 
less features implemented.

> Congrads to all you guys on mod_perl, I've heard about it and things like
> fastCGI for what seems like forever but until we got to the point where we
> were getting 1.8 million hits a day and everything was crawling as it was
> 99% perl, I never took the time to get into it - after the 300% performance
> increase seen after converting the entire site I simply cannot live without
> it and I refuse to do even the smallest projects using anything else.

Fantastic.

Perhaps you would like to submit a success story for our collection at:
http://perl.apache.org/outstanding/success_stories/index.html

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


RE: Using a Startup.pl

Posted by Chris Faust <CF...@doyougot.com>.
Thanks for the explanation and the details Stas,

I'm actually OK with everything in my startup.pl being available to all
virtual hosts.
After reading the post from Thomas I went back in and removed all the
"perlModule" and "perlRequire" lines from the virtual host containers and
loaded everything at once outside of the VHosts and it seems to have
corrected my problems. Its good to know if there is a need to divide it the
ability is there to do so (looks like I was doing it but without creating a
new parent interpreter).

I am using mod_perl 1.99.08, this is my second dev server and I've found
that RH is OK as a OS but I've had MUCH better results leaving it at that
and installing Apache, mod_perl and mySql etc. from source and not as part
of the RH install or using RPMs..

Congrads to all you guys on mod_perl, I've heard about it and things like
fastCGI for what seems like forever but until we got to the point where we
were getting 1.8 million hits a day and everything was crawling as it was
99% perl, I never took the time to get into it - after the 300% performance
increase seen after converting the entire site I simply cannot live without
it and I refuse to do even the smallest projects using anything else.

-Chris



>> -----Original Message-----
>> From: Stas Bekman [mailto:stas@stason.org]
>> Sent: Tuesday, March 18, 2003 5:34 PM
>> To: Thomas Klausner
>> Cc: Modperl
>> Subject: Re: Using a Startup.pl
>>
>>
>> Thomas Klausner wrote:
>> > Hi!
>> >
>> > On Tue, Mar 18, 2003 at 01:39:41PM -0500, Chris Faust wrote:
>> >
>> >
>> >>I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm
>> using NamedBased
>> >>Virtual Hosting in apache (so I have a number of virtual hosts
>> and apache
>> >>directs properly based on hostname).
>> >>
>> >>I use a startup.pl to load up common things like DBI, CGI,
>> HTML::Template
>> >>etc..
>> >>
>> >>Should I have just a single startup.pl and will that work with
>> all virtual
>> >>hosts? Or should I have a startup.pl per virtual host.
>> >
>> >
>> > AFAIK, and with mod_perl 1.x, having multiple startup.pl's
>> makes no sense as
>> > they all get executed during server startup and in the main namespace.
>>
>> That's correct only for mod_perl 1.0.
>>
>> For mod_perl 2.0 this depends on whether 'PerlOptions +Parent'
>> is set or not.
>> If it is each vhost can have their own startup.pl (only that
>> vhost will ever
>> execute/see the code that run from it). It's documented here:
>> http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_
>>
>> (though as someone reported PerlOptions +Parent doesn't work inside the
>> <Location> container, I haven't had a chance to work on it yet.)
>>
>> However this is all new code and not very tested yet, so I won't
>> be surprised
>> if there are problems with it. If you have problems report them
>> as explained here:
>> http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems
>>
>> __________________________________________________________________
>> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
>> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
>> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
>> http://modperlbook.org http://apache.org   http://ticketmaster.com



Re: Using a Startup.pl

Posted by Stas Bekman <st...@stason.org>.
Thomas Klausner wrote:
> Hi!
> 
> On Tue, Mar 18, 2003 at 01:39:41PM -0500, Chris Faust wrote:
> 
> 
>>I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm using NamedBased
>>Virtual Hosting in apache (so I have a number of virtual hosts and apache
>>directs properly based on hostname).
>>
>>I use a startup.pl to load up common things like DBI, CGI, HTML::Template
>>etc..
>>
>>Should I have just a single startup.pl and will that work with all virtual
>>hosts? Or should I have a startup.pl per virtual host.
> 
> 
> AFAIK, and with mod_perl 1.x, having multiple startup.pl's makes no sense as
> they all get executed during server startup and in the main namespace.

That's correct only for mod_perl 1.0.

For mod_perl 2.0 this depends on whether 'PerlOptions +Parent' is set or not. 
If it is each vhost can have their own startup.pl (only that vhost will ever 
execute/see the code that run from it). It's documented here:
http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_

(though as someone reported PerlOptions +Parent doesn't work inside the 
<Location> container, I haven't had a chance to work on it yet.)

However this is all new code and not very tested yet, so I won't be surprised 
if there are problems with it. If you have problems report them as explained here:
http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


RE: Using a Startup.pl

Posted by Chris Faust <CF...@doyougot.com>.
Thanks Thomas, that is what I wanted to know!!

-Chris


>> -----Original Message-----
>> From: Thomas Klausner [mailto:domm@zsi.at]
>> Sent: Tuesday, March 18, 2003 1:50 PM
>> To: Modperl
>> Subject: Re: Using a Startup.pl
>> 
>> 
>> Hi!
>> 
>> On Tue, Mar 18, 2003 at 01:39:41PM -0500, Chris Faust wrote:
>> 
>> > I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm 
>> using NamedBased
>> > Virtual Hosting in apache (so I have a number of virtual hosts 
>> and apache
>> > directs properly based on hostname).
>> > 
>> > I use a startup.pl to load up common things like DBI, CGI, 
>> HTML::Template
>> > etc..
>> > 
>> > Should I have just a single startup.pl and will that work with 
>> all virtual
>> > hosts? Or should I have a startup.pl per virtual host.
>> 
>> AFAIK, and with mod_perl 1.x, having multiple startup.pl's makes 
>> no sense as
>> they all get executed during server startup and in the main namespace. 
>> 
>> 
>> -- 
>> #!/usr/bin/perl                               http://domm.zsi.at
>> for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


Re: Using a Startup.pl

Posted by Thomas Klausner <do...@zsi.at>.
Hi!

On Tue, Mar 18, 2003 at 01:39:41PM -0500, Chris Faust wrote:

> I'm running mod_perl 2 on RedHat with Apache 2.0.44 and I'm using NamedBased
> Virtual Hosting in apache (so I have a number of virtual hosts and apache
> directs properly based on hostname).
> 
> I use a startup.pl to load up common things like DBI, CGI, HTML::Template
> etc..
> 
> Should I have just a single startup.pl and will that work with all virtual
> hosts? Or should I have a startup.pl per virtual host.

AFAIK, and with mod_perl 1.x, having multiple startup.pl's makes no sense as
they all get executed during server startup and in the main namespace. 


-- 
#!/usr/bin/perl                               http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}