You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bruno Lavoie <br...@gmail.com> on 2005/02/21 14:40:08 UTC

Apache 2 + mod_perl + virtual host problems

Hello,

my problem is very confusing! and i absolutely need it working!
at work i need to configure multiples developement zone under apache 2
and mod_perl 2, and this as virtual host for each programmer. I need
to run environement in ModPerl::PerlRun because we have dirty scripts
that doesnt work under ModPerl::Registry

i'm running on a debian box with :

Apache/2.0.52 (Debian GNU/Linux) PHP/4.3.10-2 mod_perl/1.999.20 Perl/v5.8.4

and here is my virtual host settings :


<VirtualHost *>

        ServerName      developername.domain.com
        ServerAdmin     my@mail.domain
        ServerSignature On

        LogLevel  warn
        ErrorLog  /fsg/intranet-fsgbla/logs/apache-error.log
        CustomLog /fsg/intranet-fsgbla/logs/apache-common.log common

        DocumentRoot /fsg/intranet-fsgbla/htdocs/


        PerlModule Apache2
        PerlModule ModPerl::PerlRun  
        PerlOptions +Parent
        PerlSwitches -Mlib=/fsg/intranet-fsgbla/htdocs

        <Files ~ ".pl$">
                SetHandler perl-script
                PerlResponseHandler ModPerl::PerlRun
                PerlOptions +ParseHeaders
                Options +ExecCGI
        </Files>

        <Location /perl-status>
                SetHandler perl-script
                PerlHandler Apache::Status
        </Location>

</VirtualHost>




the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the
<Files ~ ...> directives scope dont call scripts, my error log show me
when i call a .pl file :
Code:

[Thu Feb 17 10:02:55 2005] [error] /fsg/intranet-fsgbla/htdocs/test.pl
not found or unable to stat



when i change the ModPerl::PerlRun to ModPerl::Registry, IT WORKS? no
errors in error log file! WHY?

i tried a lot of thing and i'm very out of ideas?

someone knows it?

thanks a lot
Bruno

Re: Apache 2 + mod_perl + virtual host problems

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-02-21 at 11:49 -0300, Leo wrote:
> <IfModule mod_perl.c>
>     <Directory /home/*/public_html/cgi-bin>
>         SetHandler perl-script
>         PerlResponseHandler ModPerl::PerlRun
>         Options +ExecCGI
>         <IfDefine MODPERL2>
>           PerlOptions +ParseHeaders
>         </IfDefine>
>         <IfDefine !MODPERL2>
>           PerlSendHeader On
>         </IfDefine>
>     </Directory> 
> </IfModule>

Note that this config will not work with mod_perl 1.x, despite the
IfDefines, because it uses ModPerl::PerlRun and PerlResponseHandler.

- Perrin


Re: Apache 2 + mod_perl + virtual host problems

Posted by Leo <le...@secline.com.br>.
Your .pl file is not being executed.

It must be in the cgi-bin directory for ModPerl::PerlRun to do anything.

I tested your <Files ~ ".pl$"> apache config and it functioned for my 
test.pl even outside the cgi-bin directory.

You mentioned in a previous post your reasons for using vhosts...  I am 
not familiar enough with ModPerl::PerlRun or ModPerl::Registry to be 
able to provide reasons for the error in the original post.

It's better if someone more knowledgeable about these issues provide you 
more clarification. 

Bruno Lavoie wrote:

>i tried the user_dir public_html config
>
>this is :
>
>
><IfModule mod_userdir.c>
>        UserDir public_html
>        UserDir disabled root
>
>        <Directory /home/*/public_html>
>                AllowOverride FileInfo AuthConfig Limit
>                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
>        </Directory>
>
>        PerlModule ModPerl::PerlRun
>        <Directory /home/*/public_html/cgi-bin>            
>                SetHandler perl-script
>                PerlResponseHandler ModPerl::PerlRun
>                Options +ExecCGI
>                PerlOptions +ParseHeaders        
>        </Directory> 
></IfModule>
>
>and my .pl file is not executed..... the browser return me the .pl
>file for download and i can see the script source....
>
>and the file is chmod a+x
>
>:( 
>
>
>
>
>On Mon, 21 Feb 2005 11:49:40 -0300, Leo <le...@secline.com.br> wrote:
>  
>
>> Bruno:
>> 
>> If you use public_html for each user, you might be able to configure a
>>cgi-bin directory therein for testing such "dirty scripts" .
>> 
>> This is a modification of the default configuration of Apache2 on Gentoo...
>> 
>> <IfModule mod_perl.c>
>>     <Directory /home/*/public_html/cgi-bin>
>>         SetHandler perl-script
>>         PerlResponseHandler ModPerl::PerlRun
>>         Options +ExecCGI
>>         <IfDefine MODPERL2>
>>           PerlOptions +ParseHeaders
>>         </IfDefine>
>>         <IfDefine !MODPERL2>
>>           PerlSendHeader On
>>         </IfDefine>
>>     </Directory> 
>> </IfModule>
>> 
>> If you really need virtual hosts and have mod_vhosts_alias try this config
>>modified from gentoo virtual_homepages.conf
>> It assumes your virtual hosts are at /www/hosts
>> 
>> See the documentation for mod_vhost_alias for details.
>> 
>> #A virtually hosted homepages system
>> #
>> #   This is an adjustment of the above system tailored for an ISP's
>> #   homepages server. Using a slightly more complicated configuration we
>>can
>> #   select substrings of the server name to use in the filename so that
>>e.g.
>> #   the documents for www.user.isp.com are found in /home/user/. It uses a
>> #   single cgi-bin directory instead of one per virtual host.
>> 
>> # get the server name from the Host: header
>> #UseCanonicalName Off
>> 
>> # include part of the server name in the filenames
>> VirtualDocumentRoot /www/hosts/%2/docs
>> 
>> # single cgi-bin directory
>> ScriptAlias  /cgi-bin/  /www/std-cgi/
>> 
>> # if you are happy not using modperl for cgi scripts
>> # VirtualScriptAlias /cgi-bin/ /www/hosts/%2/cgi-bin/
>>   
>> # if you need modperl for cgi scripts                                   
>> <IfModule mod_perl.c>
>>     # foreach virtual host repeat the following
>>     <Directory /www/hosts/userfred.mydomain.com/cgi-bin>
>>         SetHandler perl-script
>>         PerlResponseHandler ModPerl::PerlRun
>>         Options +ExecCGI
>>         <IfDefine MODPERL2>
>>           PerlOptions +ParseHeaders
>>         </IfDefine>
>>         <IfDefine !MODPERL2>
>>           PerlSendHeader On
>>         </IfDefine>
>>     </Directory> 
>>     ...
>> </IfModule>
>> 
>> Also you may have to modify your VirtualDocumentRoot and VirtualScriptAlias
>>or the PerlRun Directory configs to reflect the real location of your
>>virtual domains.
>> 
>> Be sure your DNS is configured with all the virtual hosts you need.
>> 
>> Also note that I haven't tested any of these configs with debian Apache2.
>>But maybe it will give you a starting point.
>> 
>> please correct me where I may have made errors.
>> 
>> Leo
>>    
>>
>  
>


Re: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
i tried the user_dir public_html config

this is :


<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        </Directory>

        PerlModule ModPerl::PerlRun
        <Directory /home/*/public_html/cgi-bin>            
                SetHandler perl-script
                PerlResponseHandler ModPerl::PerlRun
                Options +ExecCGI
                PerlOptions +ParseHeaders        
        </Directory> 
</IfModule>

and my .pl file is not executed..... the browser return me the .pl
file for download and i can see the script source....

and the file is chmod a+x

:( 




On Mon, 21 Feb 2005 11:49:40 -0300, Leo <le...@secline.com.br> wrote:
>  Bruno:
>  
>  If you use public_html for each user, you might be able to configure a
> cgi-bin directory therein for testing such "dirty scripts" .
>  
>  This is a modification of the default configuration of Apache2 on Gentoo...
>  
>  <IfModule mod_perl.c>
>      <Directory /home/*/public_html/cgi-bin>
>          SetHandler perl-script
>          PerlResponseHandler ModPerl::PerlRun
>          Options +ExecCGI
>          <IfDefine MODPERL2>
>            PerlOptions +ParseHeaders
>          </IfDefine>
>          <IfDefine !MODPERL2>
>            PerlSendHeader On
>          </IfDefine>
>      </Directory> 
>  </IfModule>
>  
>  If you really need virtual hosts and have mod_vhosts_alias try this config
> modified from gentoo virtual_homepages.conf
>  It assumes your virtual hosts are at /www/hosts
>  
>  See the documentation for mod_vhost_alias for details.
>  
>  #A virtually hosted homepages system
>  #
>  #   This is an adjustment of the above system tailored for an ISP's
>  #   homepages server. Using a slightly more complicated configuration we
> can
>  #   select substrings of the server name to use in the filename so that
> e.g.
>  #   the documents for www.user.isp.com are found in /home/user/. It uses a
>  #   single cgi-bin directory instead of one per virtual host.
>  
>  # get the server name from the Host: header
>  #UseCanonicalName Off
>  
>  # include part of the server name in the filenames
>  VirtualDocumentRoot /www/hosts/%2/docs
>  
>  # single cgi-bin directory
>  ScriptAlias  /cgi-bin/  /www/std-cgi/
>  
>  # if you are happy not using modperl for cgi scripts
>  # VirtualScriptAlias /cgi-bin/ /www/hosts/%2/cgi-bin/
>    
>  # if you need modperl for cgi scripts                                   
>  <IfModule mod_perl.c>
>      # foreach virtual host repeat the following
>      <Directory /www/hosts/userfred.mydomain.com/cgi-bin>
>          SetHandler perl-script
>          PerlResponseHandler ModPerl::PerlRun
>          Options +ExecCGI
>          <IfDefine MODPERL2>
>            PerlOptions +ParseHeaders
>          </IfDefine>
>          <IfDefine !MODPERL2>
>            PerlSendHeader On
>          </IfDefine>
>      </Directory> 
>      ...
>  </IfModule>
>  
>  Also you may have to modify your VirtualDocumentRoot and VirtualScriptAlias
> or the PerlRun Directory configs to reflect the real location of your
> virtual domains.
>  
>  Be sure your DNS is configured with all the virtual hosts you need.
>  
>  Also note that I haven't tested any of these configs with debian Apache2.
> But maybe it will give you a starting point.
>  
>  please correct me where I may have made errors.
>  
>  Leo
> 
>  
>  Bruno Lavoie wrote: 
>  Hello, my problem is very confusing! and i absolutely need it working! at
> work i need to configure multiples developement zone under apache 2 and
> mod_perl 2, and this as virtual host for each programmer. I need to run
> environement in ModPerl::PerlRun because we have dirty scripts that doesnt
> work under ModPerl::Registry i'm running on a debian box with :
> Apache/2.0.52 (Debian GNU/Linux) PHP/4.3.10-2 mod_perl/1.999.20 Perl/v5.8.4
> and here is my virtual host settings : <VirtualHost *> ServerName
> developername.domain.com ServerAdmin my@mail.domain ServerSignature On
> LogLevel warn ErrorLog /fsg/intranet-fsgbla/logs/apache-error.log CustomLog
> /fsg/intranet-fsgbla/logs/apache-common.log common DocumentRoot
> /fsg/intranet-fsgbla/htdocs/ PerlModule Apache2 PerlModule ModPerl::PerlRun
> PerlOptions +Parent PerlSwitches -Mlib=/fsg/intranet-fsgbla/htdocs <Files ~
> ".pl$"> SetHandler perl-script PerlResponseHandler ModPerl::PerlRun
> PerlOptions +ParseHeaders Options +ExecCGI </Files> <Location /perl-status>
> SetHandler perl-script PerlHandler Apache::Status </Location> </VirtualHost>
> the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the <Files
> ~ ...> directives scope dont call scripts, my error log show me when i call
> a .pl file : Code: [Thu Feb 17 10:02:55 2005] [error]
> /fsg/intranet-fsgbla/htdocs/test.pl not found or unable to stat when i
> change the ModPerl::PerlRun to ModPerl::Registry, IT WORKS? no errors in
> error log file! WHY? i tried a lot of thing and i'm very out of ideas?
> someone knows it? thanks a lot Bruno 
>

Re: Apache 2 + mod_perl + virtual host problems

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-02-21 at 13:54 -0500, Bruno Lavoie wrote:
> ok, i'll try to run different server for each developper, mod_perl2
> seem to be able to do this rather than mod_perl 1.x

It works with either one.

> and will this 2 servers have different @INC paths??? (my original problem)

Yes, you can set @INC differently for each one.

- Perrin


Re: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
ok, i'll try to run different server for each developper, mod_perl2
seem to be able to do this rather than mod_perl 1.x

and will this 2 servers have different @INC paths??? (my original problem)

thanks
Bruno


On Mon, 21 Feb 2005 13:38:07 -0500, Perrin Harkins <pe...@elem.com> wrote:
> On Mon, 2005-02-21 at 13:31 -0500, Bruno Lavoie wrote:
> > apache2-mpm-prefork model, should i change this?
> > i think that if i run php under apache2 i need to run prefork
> > model..... debian automaticaly switched me to this mpm model when i
> > installed mod_php4
> 
> My advice is to keep running prefork, but give up on your idea of
> running virtual hosts and just run a separate apache server for each
> developer.  It's a lot simpler in the long run.  Read the documentation
> at the link I sent you in my last mail.
> 
> - Perrin
> 
>

Re: Apache 2 + mod_perl + virtual host problems

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-02-21 at 13:31 -0500, Bruno Lavoie wrote:
> apache2-mpm-prefork model, should i change this? 
> i think that if i run php under apache2 i need to run prefork
> model..... debian automaticaly switched me to this mpm model when i
> installed mod_php4

My advice is to keep running prefork, but give up on your idea of
running virtual hosts and just run a separate apache server for each
developer.  It's a lot simpler in the long run.  Read the documentation
at the link I sent you in my last mail.

- Perrin


Re: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
Hello,

i'm running on : 
apache2-mpm-prefork model, should i change this? 
i think that if i run php under apache2 i need to run prefork
model..... debian automaticaly switched me to this mpm model when i
installed mod_php4

i can deinstall php for testing purpose if i need to change the mpm model...


pl;ease help me


On Mon, 21 Feb 2005 13:13:46 -0500, Perrin Harkins <pe...@elem.com> wrote:
> On Mon, 2005-02-21 at 09:58 -0500, Bruno Lavoie wrote:
> > i need virtual host to have unique  @INC on per virtual host basis:
> > http://perl.apache.org/docs/2.0/user/config/config.html#Modifying_C__INC__on_a_Per_VirtualHost
> 
> I could be worng about this, but I think that only works if you are
> running a threaded MPM.  Are you running the "worker" MPM?
> 
> In general, I would say it's less trouble to simply run different apache
> servers for each developer so that they can stop and start them at will.
> You can run them all on the same machine, on different ports.  This
> technique is documented here:
> http://perl.apache.org/docs/general/control/control.html#Starting_a_Personal_Server_for_Each_Developer
> 
> - Perrin
> 
>

Re: Apache 2 + mod_perl + virtual host problems

Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
> On Mon, 2005-02-21 at 09:58 -0500, Bruno Lavoie wrote:
> 
>>i need virtual host to have unique  @INC on per virtual host basis:
>>http://perl.apache.org/docs/2.0/user/config/config.html#Modifying_C__INC__on_a_Per_VirtualHost
> 
> 
> I could be worng about this, but I think that only works if you are
> running a threaded MPM.  Are you running the "worker" MPM?

It works under any MPM with threaded perl. It's just that under prefork 
your procs will be huge, because you will build a pool of interpreters in 
each process. the same happens under threaded mpm, but there you have many 
threads per process, so you need just 1 or 2 procs.

I'll update the docs to mention that.

-- 
__________________________________________________________________
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: Apache 2 + mod_perl + virtual host problems

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-02-21 at 09:58 -0500, Bruno Lavoie wrote:
> i need virtual host to have unique  @INC on per virtual host basis:
> http://perl.apache.org/docs/2.0/user/config/config.html#Modifying_C__INC__on_a_Per_VirtualHost

I could be worng about this, but I think that only works if you are
running a threaded MPM.  Are you running the "worker" MPM?

In general, I would say it's less trouble to simply run different apache
servers for each developer so that they can stop and start them at will.
You can run them all on the same machine, on different ports.  This
technique is documented here:
http://perl.apache.org/docs/general/control/control.html#Starting_a_Personal_Server_for_Each_Developer

- Perrin


Re: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
humm, 

i need virtual host to have unique  @INC on per virtual host basis:
http://perl.apache.org/docs/2.0/user/config/config.html#Modifying_C__INC__on_a_Per_VirtualHost

because i need each developper to use their own librairies version in
devel stage...


its hard to me to have a cgi-bin to run these scripts, the website
under developpement is structured as follow :

/login.pl
/images/*.jpg *.gif  ........
/application1/main.pl
/application1/*.pl
/application1/images/*.jpg *.gif  ........
.......
/application2/*.pl
.......

i dont want to have a /cgi-bin path for the website....
i just want all the .pl to be treated as perl-run cgi scripts

is it possible? maybe is it a debian bug or perl + mod_perl  + apache
version combination that makes me trouble?

thx

On Mon, 21 Feb 2005 11:49:40 -0300, Leo <le...@secline.com.br> wrote:
>  Bruno:
>  
>  If you use public_html for each user, you might be able to configure a
> cgi-bin directory therein for testing such "dirty scripts" .
>  
>  This is a modification of the default configuration of Apache2 on Gentoo...
>  
>  <IfModule mod_perl.c>
>      <Directory /home/*/public_html/cgi-bin>
>          SetHandler perl-script
>          PerlResponseHandler ModPerl::PerlRun
>          Options +ExecCGI
>          <IfDefine MODPERL2>
>            PerlOptions +ParseHeaders
>          </IfDefine>
>          <IfDefine !MODPERL2>
>            PerlSendHeader On
>          </IfDefine>
>      </Directory> 
>  </IfModule>
>  
>  If you really need virtual hosts and have mod_vhosts_alias try this config
> modified from gentoo virtual_homepages.conf
>  It assumes your virtual hosts are at /www/hosts
>  
>  See the documentation for mod_vhost_alias for details.
>  
>  #A virtually hosted homepages system
>  #
>  #   This is an adjustment of the above system tailored for an ISP's
>  #   homepages server. Using a slightly more complicated configuration we
> can
>  #   select substrings of the server name to use in the filename so that
> e.g.
>  #   the documents for www.user.isp.com are found in /home/user/. It uses a
>  #   single cgi-bin directory instead of one per virtual host.
>  
>  # get the server name from the Host: header
>  #UseCanonicalName Off
>  
>  # include part of the server name in the filenames
>  VirtualDocumentRoot /www/hosts/%2/docs
>  
>  # single cgi-bin directory
>  ScriptAlias  /cgi-bin/  /www/std-cgi/
>  
>  # if you are happy not using modperl for cgi scripts
>  # VirtualScriptAlias /cgi-bin/ /www/hosts/%2/cgi-bin/
>    
>  # if you need modperl for cgi scripts                                   
>  <IfModule mod_perl.c>
>      # foreach virtual host repeat the following
>      <Directory /www/hosts/userfred.mydomain.com/cgi-bin>
>          SetHandler perl-script
>          PerlResponseHandler ModPerl::PerlRun
>          Options +ExecCGI
>          <IfDefine MODPERL2>
>            PerlOptions +ParseHeaders
>          </IfDefine>
>          <IfDefine !MODPERL2>
>            PerlSendHeader On
>          </IfDefine>
>      </Directory> 
>      ...
>  </IfModule>
>  
>  Also you may have to modify your VirtualDocumentRoot and VirtualScriptAlias
> or the PerlRun Directory configs to reflect the real location of your
> virtual domains.
>  
>  Be sure your DNS is configured with all the virtual hosts you need.
>  
>  Also note that I haven't tested any of these configs with debian Apache2.
> But maybe it will give you a starting point.
>  
>  please correct me where I may have made errors.
>  
>  Leo
> 
>  
>  Bruno Lavoie wrote: 
>  Hello, my problem is very confusing! and i absolutely need it working! at
> work i need to configure multiples developement zone under apache 2 and
> mod_perl 2, and this as virtual host for each programmer. I need to run
> environement in ModPerl::PerlRun because we have dirty scripts that doesnt
> work under ModPerl::Registry i'm running on a debian box with :
> Apache/2.0.52 (Debian GNU/Linux) PHP/4.3.10-2 mod_perl/1.999.20 Perl/v5.8.4
> and here is my virtual host settings : <VirtualHost *> ServerName
> developername.domain.com ServerAdmin my@mail.domain ServerSignature On
> LogLevel warn ErrorLog /fsg/intranet-fsgbla/logs/apache-error.log CustomLog
> /fsg/intranet-fsgbla/logs/apache-common.log common DocumentRoot
> /fsg/intranet-fsgbla/htdocs/ PerlModule Apache2 PerlModule ModPerl::PerlRun
> PerlOptions +Parent PerlSwitches -Mlib=/fsg/intranet-fsgbla/htdocs <Files ~
> ".pl$"> SetHandler perl-script PerlResponseHandler ModPerl::PerlRun
> PerlOptions +ParseHeaders Options +ExecCGI </Files> <Location /perl-status>
> SetHandler perl-script PerlHandler Apache::Status </Location> </VirtualHost>
> the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the <Files
> ~ ...> directives scope dont call scripts, my error log show me when i call
> a .pl file : Code: [Thu Feb 17 10:02:55 2005] [error]
> /fsg/intranet-fsgbla/htdocs/test.pl not found or unable to stat when i
> change the ModPerl::PerlRun to ModPerl::Registry, IT WORKS? no errors in
> error log file! WHY? i tried a lot of thing and i'm very out of ideas?
> someone knows it? thanks a lot Bruno 
>

Re: Apache 2 + mod_perl + virtual host problems

Posted by Leo <le...@secline.com.br>.
Bruno:

If you use public_html for each user, you might be able to configure a 
cgi-bin directory therein for testing such "dirty scripts" .

This is a modification of the default configuration of Apache2 on Gentoo...

<IfModule mod_perl.c>
    <Directory /home/*/public_html/cgi-bin>
        SetHandler perl-script
        PerlResponseHandler ModPerl::PerlRun
        Options +ExecCGI
        <IfDefine MODPERL2>
          PerlOptions +ParseHeaders
        </IfDefine>
        <IfDefine !MODPERL2>
          PerlSendHeader On
        </IfDefine>
    </Directory>
</IfModule>

If you really need virtual hosts and have mod_vhosts_alias try this 
config modified from gentoo virtual_homepages.conf
It assumes your virtual hosts are at /www/hosts

See the documentation for mod_vhost_alias for details.

#A virtually hosted homepages system
#
#   This is an adjustment of the above system tailored for an ISP's
#   homepages server. Using a slightly more complicated configuration we can
#   select substrings of the server name to use in the filename so that e.g.
#   the documents for www.user.isp.com are found in /home/user/. It uses a
#   single cgi-bin directory instead of one per virtual host.

# get the server name from the Host: header
#UseCanonicalName Off

# include part of the server name in the filenames
VirtualDocumentRoot /www/hosts/%2/docs

# single cgi-bin directory
ScriptAlias  /cgi-bin/  /www/std-cgi/

# if you are happy not using modperl for cgi scripts
# VirtualScriptAlias /cgi-bin/ /www/hosts/%2/cgi-bin/
 
# if you need modperl for cgi scripts                                  
<IfModule mod_perl.c>
    # foreach virtual host repeat the following
    <Directory /www/hosts/userfred.mydomain.com/cgi-bin>
        SetHandler perl-script
        PerlResponseHandler ModPerl::PerlRun
        Options +ExecCGI
        <IfDefine MODPERL2>
          PerlOptions +ParseHeaders
        </IfDefine>
        <IfDefine !MODPERL2>
          PerlSendHeader On
        </IfDefine>
    </Directory>
    ...
</IfModule>

Also you may have to modify your VirtualDocumentRoot and 
VirtualScriptAlias or the PerlRun Directory configs to reflect the real 
location of your virtual domains.

Be sure your DNS is configured with all the virtual hosts you need.

Also note that I haven't tested any of these configs with debian 
Apache2. But maybe it will give you a starting point.

please correct me where I may have made errors.

Leo

Bruno Lavoie wrote:

>Hello,
>
>my problem is very confusing! and i absolutely need it working!
>at work i need to configure multiples developement zone under apache 2
>and mod_perl 2, and this as virtual host for each programmer. I need
>to run environement in ModPerl::PerlRun because we have dirty scripts
>that doesnt work under ModPerl::Registry
>
>i'm running on a debian box with :
>
>Apache/2.0.52 (Debian GNU/Linux) PHP/4.3.10-2 mod_perl/1.999.20 Perl/v5.8.4
>
>and here is my virtual host settings :
>
>
><VirtualHost *>
>
>        ServerName      developername.domain.com
>        ServerAdmin     my@mail.domain
>        ServerSignature On
>
>        LogLevel  warn
>        ErrorLog  /fsg/intranet-fsgbla/logs/apache-error.log
>        CustomLog /fsg/intranet-fsgbla/logs/apache-common.log common
>
>        DocumentRoot /fsg/intranet-fsgbla/htdocs/
>
>
>        PerlModule Apache2
>        PerlModule ModPerl::PerlRun  
>        PerlOptions +Parent
>        PerlSwitches -Mlib=/fsg/intranet-fsgbla/htdocs
>
>        <Files ~ ".pl$">
>                SetHandler perl-script
>                PerlResponseHandler ModPerl::PerlRun
>                PerlOptions +ParseHeaders
>                Options +ExecCGI
>        </Files>
>
>        <Location /perl-status>
>                SetHandler perl-script
>                PerlHandler Apache::Status
>        </Location>
>
></VirtualHost>
>
>
>
>
>the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the
><Files ~ ...> directives scope dont call scripts, my error log show me
>when i call a .pl file :
>Code:
>
>[Thu Feb 17 10:02:55 2005] [error] /fsg/intranet-fsgbla/htdocs/test.pl
>not found or unable to stat
>
>
>
>when i change the ModPerl::PerlRun to ModPerl::Registry, IT WORKS? no
>errors in error log file! WHY?
>
>i tried a lot of thing and i'm very out of ideas?
>
>someone knows it?
>
>thanks a lot
>Bruno
>
>
>  
>


Re: Apache 2 + mod_perl + virtual host problems

Posted by Stas Bekman <st...@stason.org>.
Bruno Lavoie wrote:
> hummmmmmm
> 
> i tried to hack the code in RegistryCooker.pm and i saw that the files
> differ from FreeBSD to Debian
[...]
> HUMMMMMMMMMMMMM that's not the same source, but i dont really
> understand, the mod_perl is the same version for the to systems......!
> mod_perl/1.999.20
> 
> why on one it's $r->filename and on the other one is it $r->my_finfo ?????
> 
> should I notice the Debian Guys to change it or not ?
> is it safe to play in this code? when i'll update my packages, i'll
> lost the change....

Looks like this might be your problem, as you are not running the same 
code. I'd first suggest installing from source you download from 
perl.apache.org and see if helps.

> thanks to you Stas for the tricks.. but... this is a problem.... will
> others like this one surprise me?

the life would be boring if you knew that there will be no more surprises :)

-- 
__________________________________________________________________
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: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
hummmmmmm

i tried to hack the code in RegistryCooker.pm and i saw that the files
differ from FreeBSD to Debian

let's look

Freebsd:

/usr/local/lib/perl5/site_perl/5.8.6/mach/Apache2/ModPerl/RegistryCooker.pm
sub can_compile {
    my $self = shift;
    my $r = $self->{REQ};

    unless (-r $r->my_finfo && -s _) {
        $self->log_error("$self->{FILENAME} not found or unable to stat");
        return Apache::NOT_FOUND;
    }

    return Apache::DECLINED if -d _;


Debian:
/usr/lib/perl5/Apache2/ModPerl/RegistryCooker.pm
sub can_compile {
    my $self = shift;
    my $r = $self->{REQ};

    unless (-r $r->filename && -s _) { 
        $self->log_error("$self->{FILENAME} not found or unable to stat"); 
        return Apache::NOT_FOUND; 
    }


HUMMMMMMMMMMMMM that's not the same source, but i dont really
understand, the mod_perl is the same version for the to systems......!
mod_perl/1.999.20

why on one it's $r->filename and on the other one is it $r->my_finfo ?????

should I notice the Debian Guys to change it or not ?
is it safe to play in this code? when i'll update my packages, i'll
lost the change....

thanks to you Stas for the tricks.. but... this is a problem.... will
others like this one surprise me?

thanks for all the help! 
Bruno Lavoie

Re: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
now strange, i changed nothing, restarted server twice, and the server
wants me to download the script rather than execute it.......

let's look at my config files at:

http://w3.ift.ulaval.ca/~brlav35/apache2conf/

the main 2 files are :

apache2.conf 
/sites-enabled/000-default

i hope someone find my problem

Bruno

On Mon, 21 Feb 2005 21:40:36 -0500, Stas Bekman <st...@stason.org> wrote:
> Bruno Lavoie wrote:
> > OK,
> >
> > i'm not a mod_perl hacker, but i've installed a Apache2 + mod_perl2
> > under a FreeBSD VMWare to test, i used the same mod_perl2
> > configuration...... same script!  I copy paste this config in the
> > global server config or default vhost:
> >
> > #
> > ####
> > PerlModule ModPerl::PerlRun
> > Alias /perl-run/ /usr/local/www/perl/
> > <Location /perl-run>
> >     SetHandler perl-script
> >     PerlResponseHandler ModPerl::PerlRun
> >     PerlOptions +ParseHeaders
> >     Options +ExecCGI
> > </Location>
> >
> > as you can see, it's very basic! It works on FreeBSD not under Debian
> > Sarge.... the same error,
> >
> > [Mon Feb 21 21:27:41 2005] [error] /usr/local/www/perl/test.pl not
> > found or unable to stat
> >
> > and when i do a 'cat /usr/local/www/perl/test.pl' the file exists,
> > executable, etc...... everything is OK, if it runs under
> > Registry.......
> >
> > but check out my different HEAD output
> >
> > FreeBSD :
> > Server: Apache/2.0.53 (FreeBSD) mod_perl/1.999.20 Perl/v5.8.6
> >
> > Debian:
> > Server: Apache/2.0.52 (Debian GNU/Linux) mod_perl/1.999.20 Perl/v5.8.4
> >
> > Can the perl version change anything? can the apache version change anything?
> > I can post all my debian apache 2 config files......... if it's necessary
> 
> it's hard to tell, I prefer debugging:
> 
> > or with you Stas, i can jump into debuging like the way you talked in
> > the last post...
> 
> Actually it's easier that that. the error comes from RegistryCooker.pm:
> 
> sub can_compile {
>      my $self = shift;
>      my $r = $self->{REQ};
> 
>      unless (-r $r->my_finfo && -s _) {
>          $self->log_error("$self->{FILENAME} not found or unable to stat");
>          return Apache::NOT_FOUND;
>      }
> 
> and my_finfo later on:
> 
> # XXX: should go away when finfo() is ported to 2.0 (don't want to
> # depend on compat.pm)
> sub Apache::RequestRec::my_finfo {
>      my $r = shift;
>      stat $r->filename;
>      \*_;
> }
> 
> so what do you get in error log if you dump this:
> 
>    warn "filename: ". $r->filename . "\n";
> 
> --
> __________________________________________________________________
> 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: Apache 2 + mod_perl + virtual host problems

Posted by Stas Bekman <st...@stason.org>.
Bruno Lavoie wrote:
> OK, 
> 
> i'm not a mod_perl hacker, but i've installed a Apache2 + mod_perl2
> under a FreeBSD VMWare to test, i used the same mod_perl2
> configuration...... same script!  I copy paste this config in the
> global server config or default vhost:
> 
> #
> ####
> PerlModule ModPerl::PerlRun
> Alias /perl-run/ /usr/local/www/perl/
> <Location /perl-run>
>     SetHandler perl-script
>     PerlResponseHandler ModPerl::PerlRun
>     PerlOptions +ParseHeaders
>     Options +ExecCGI
> </Location>
> 
> as you can see, it's very basic! It works on FreeBSD not under Debian
> Sarge.... the same error,
> 
> [Mon Feb 21 21:27:41 2005] [error] /usr/local/www/perl/test.pl not
> found or unable to stat
> 
> and when i do a 'cat /usr/local/www/perl/test.pl' the file exists,
> executable, etc...... everything is OK, if it runs under
> Registry.......
> 
> but check out my different HEAD output
> 
> FreeBSD : 
> Server: Apache/2.0.53 (FreeBSD) mod_perl/1.999.20 Perl/v5.8.6
> 
> Debian:
> Server: Apache/2.0.52 (Debian GNU/Linux) mod_perl/1.999.20 Perl/v5.8.4
> 
> Can the perl version change anything? can the apache version change anything?
> I can post all my debian apache 2 config files......... if it's necessary

it's hard to tell, I prefer debugging:

> or with you Stas, i can jump into debuging like the way you talked in
> the last post...

Actually it's easier that that. the error comes from RegistryCooker.pm:

sub can_compile {
     my $self = shift;
     my $r = $self->{REQ};

     unless (-r $r->my_finfo && -s _) {
         $self->log_error("$self->{FILENAME} not found or unable to stat");
         return Apache::NOT_FOUND;
     }

and my_finfo later on:

# XXX: should go away when finfo() is ported to 2.0 (don't want to
# depend on compat.pm)
sub Apache::RequestRec::my_finfo {
     my $r = shift;
     stat $r->filename;
     \*_;
}

so what do you get in error log if you dump this:

   warn "filename: ". $r->filename . "\n";

-- 
__________________________________________________________________
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: Apache 2 + mod_perl + virtual host problems

Posted by Bruno Lavoie <br...@gmail.com>.
OK, 

i'm not a mod_perl hacker, but i've installed a Apache2 + mod_perl2
under a FreeBSD VMWare to test, i used the same mod_perl2
configuration...... same script!  I copy paste this config in the
global server config or default vhost:

#
####
PerlModule ModPerl::PerlRun
Alias /perl-run/ /usr/local/www/perl/
<Location /perl-run>
    SetHandler perl-script
    PerlResponseHandler ModPerl::PerlRun
    PerlOptions +ParseHeaders
    Options +ExecCGI
</Location>

as you can see, it's very basic! It works on FreeBSD not under Debian
Sarge.... the same error,

[Mon Feb 21 21:27:41 2005] [error] /usr/local/www/perl/test.pl not
found or unable to stat

and when i do a 'cat /usr/local/www/perl/test.pl' the file exists,
executable, etc...... everything is OK, if it runs under
Registry.......

but check out my different HEAD output

FreeBSD : 
Server: Apache/2.0.53 (FreeBSD) mod_perl/1.999.20 Perl/v5.8.6

Debian:
Server: Apache/2.0.52 (Debian GNU/Linux) mod_perl/1.999.20 Perl/v5.8.4

Can the perl version change anything? can the apache version change anything?
I can post all my debian apache 2 config files......... if it's necessary

or with you Stas, i can jump into debuging like the way you talked in
the last post...

i'm on this problem for days ago...

thanks in advance
Bruno


On Mon, 21 Feb 2005 20:49:57 -0500, Stas Bekman <st...@stason.org> wrote:
> Bruno Lavoie wrote:
> > Hello,
> >
> > my problem is very confusing! and i absolutely need it working!
> > at work i need to configure multiples developement zone under apache 2
> > and mod_perl 2, and this as virtual host for each programmer. I need
> > to run environement in ModPerl::PerlRun because we have dirty scripts
> > that doesnt work under ModPerl::Registry
> [...]
> > the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the
> > <Files ~ ...> directives scope dont call scripts, my error log show me
> > when i call a .pl file :
> > Code:
> >
> > [Thu Feb 17 10:02:55 2005] [error] /fsg/intranet-fsgbla/htdocs/test.pl
> > not found or unable to stat
> 
> Where is the script physically located? At the above path? Is it
> executable and readable (I suppose so, since registry works). Also you
> could try to enable debugging in the RegistryCooker.pm and see whether it
> runs. at the end it's easy to compare Registry.pm with PerlRun.pm and try
> to see what difference creates the problem. I'd guess that this difference
> is the crucial one:
> 
> PerlRun.pm     flush_namespace => 'flush_namespace_normal',
> Registry.pm    flush_namespace => 'NOP',
> 
> the actual functions are in RegistryCooker.pm.
> 
> --
> __________________________________________________________________
> 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: Apache 2 + mod_perl + virtual host problems

Posted by Stas Bekman <st...@stason.org>.
Bruno Lavoie wrote:
> Hello,
> 
> my problem is very confusing! and i absolutely need it working!
> at work i need to configure multiples developement zone under apache 2
> and mod_perl 2, and this as virtual host for each programmer. I need
> to run environement in ModPerl::PerlRun because we have dirty scripts
> that doesnt work under ModPerl::Registry
[...]
> the weirdest thing is the PerlResponseHandler ModPerl::PerlRun in the
> <Files ~ ...> directives scope dont call scripts, my error log show me
> when i call a .pl file :
> Code:
> 
> [Thu Feb 17 10:02:55 2005] [error] /fsg/intranet-fsgbla/htdocs/test.pl
> not found or unable to stat

Where is the script physically located? At the above path? Is it 
executable and readable (I suppose so, since registry works). Also you 
could try to enable debugging in the RegistryCooker.pm and see whether it 
runs. at the end it's easy to compare Registry.pm with PerlRun.pm and try 
to see what difference creates the problem. I'd guess that this difference 
is the crucial one:

PerlRun.pm     flush_namespace => 'flush_namespace_normal',
Registry.pm    flush_namespace => 'NOP',

the actual functions are in RegistryCooker.pm.

-- 
__________________________________________________________________
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