mod_perl and access to the parent processes environment?

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default mod_perl and access to the parent processes environment?

    So how can I set up the environment prior to launching httpd so that
    these values are available in <Perl> stanza's in httpd.conf?

    It doesn't look like this is possible.

    It looks like the only thing I can do is say

    -Ddefinesomething

    and then in httpd.conf

    ifdefined definesomething
    do something

    but I need to do more than this.

    I want to be able to pass information from the script that launches
    httpd and have that information available within a <Perl> stanza.

    robert@elastica.com Guest

  2. Similar Questions and Discussions

    1. how to access user web control from parent page?
      Hi, I've created a user web control with 4 drop down list boxes in it. I've added this user control to my main web form page. I created the...
    2. Child access to parent RemoteObject
      I have an application with a RemoteObject that I want to share with child component (if that's the right term). Everything seems to work but I get...
    3. No access to parent template
      I am working around my other problem that I posted and am running into another. I have a master template that no Contribute user should be able to...
    4. Unable to access the Web Service in a RSA secured/protected environment
      Hi all, I am working on MS .NET Alerts to be implemented at our site. We have our web applications in ASP 3.0 I have created a local web service...
    5. #6674 [Com]: Apache crashes as soon as I access my server running PHP 4.0.2 + mod_perl 1.24
      ID: 6674 Comment by: peitschie at hotmail dot com Reported By: ruudc at home dot nl Status: Closed Bug Type: ...
  3. #2

    Default Re: mod_perl and access to the parent processes environment?

    [email]robert@elastica.com[/email] wrote:
    > So how can I set up the environment prior to launching httpd so that
    > these values are available in <Perl> stanza's in httpd.conf?
    Set an environment variable then access it via %ENV?
    > I want to be able to pass information from the script that launches
    > httpd and have that information available within a <Perl> stanza.
    You could also, of course, just include a file into httpd.conf which has
    the relevant values set. If necessary this included file could be created
    with the relevant values added in dynamically by the startup script.



    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue Guest

  4. #3

    Default Re: mod_perl and access to the parent processes environment?

    On 07/19/2006 07:09 PM, Big and Blue wrote:
    > [email]robert@elastica.com[/email] wrote:
    >> So how can I set up the environment prior to launching
    >> httpd so that these values are available in <Perl>
    >> stanza's in httpd.conf?
    >
    > Set an environment variable then access it via %ENV?
    >
    >> I want to be able to pass information from the script
    >> that launches httpd and have that information available
    >> within a <Perl> stanza.
    >
    > You could also, of course, just include a file into
    > httpd.conf which has the relevant values set. If necessary
    > this included file could be created with the relevant
    > values added in dynamically by the startup script.
    >
    That won't work out well because the server would have to be
    restarted.

    Robert, instead I suggest you modify an .htaccess file
    instead. Htaccess files are re-read on each access. However, I
    doubt you need to do this. Probably anything you can do in a
    <Perl> section of an Apache config file can also be done in a
    custom perl-handler.

    HTH
    Mumia W. Guest

  5. #4

    Default Re: mod_perl and access to the parent processes environment?

    Mumia W. wrote:
    >
    > That won't work out well because the server would have to be
    > restarted.
    The original question was:
    >> So how can I set up the environment prior to launching
    >> httpd.
    "prior to launching" indicates to me that this is a one-off setting at
    startup.

    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue Guest

  6. #5

    Default Re: mod_perl and access to the parent processes environment?

    Yes the general idea is that I set the environment up with the host
    specific info or at the very least hostname of the server i'm starting
    and then pull that out of %ENV later. Now I know I can use
    getbyhostname in a <perl> block but I wanted to know if my <Perl>
    stanza should be able to pull out of %ENV anything that I've
    PerlPassEnv'd. Because when I tried this it doesn't work.

    Right now I have the startup script process a dictionary and uses
    Tempate Toolkit to generate the configuration files upon startup. It's
    a very flexible approach but I wanted to know if the above approach was
    possible because I wanted another solution instead of relying on
    statically generated configuration files.. Strictly speaking they are
    dynamic but I was trying to come up with a solution that could reuse
    the same httpd.conf across all servers. I just need to have port,
    hostname amongst other things. (assume port could vary across servers,
    unlikely though)

    That said I find a solution where I can pass thru environment vars when
    I start httpd and to then evaluate those vars quite simple and elegant
    for my needs. Despite the fact that I've invested some time in coding
    the existing template based generation approach.

    1. I want to setenv VAR some value and I use PerlPassEnv in http.conf
    should I then be able to find $VAR in %ENV in any <Perl> stanza? Or is
    PerlPassEnv only used to pass thru variables to perl handlers for
    request processing with mod perl?


    Big and Blue wrote:
    > Mumia W. wrote:
    > >
    > > That won't work out well because the server would have to be
    > > restarted.
    >
    > The original question was:
    >
    > >> So how can I set up the environment prior to launching
    > >> httpd.
    >
    > "prior to launching" indicates to me that this is a one-off setting at
    > startup.
    >
    > --
    > Just because I've written it doesn't mean that
    > either you or I have to believe it.
    robert.nicholson@gmail.com Guest

  7. #6

    Default Re: mod_perl and access to the parent processes environment?

    [email]robert.nicholson@gmail.com[/email] wrote:
    >
    > Yes the general idea is that I set the environment up with the host
    > specific info or at the very least hostname of the server i'm starting
    > and then pull that out of %ENV later. Now I know I can use
    > getbyhostname in a <perl> block but I wanted to know if my <Perl>
    > stanza should be able to pull out of %ENV anything that I've
    > PerlPassEnv'd. Because when I tried this it doesn't work.
    As I mentioned before, you can always get a script, run at startup, to
    do anything you want ie: the startup script does a gethostbyname() call and
    writes the result into an Apache config file which you then include into
    your static Apache config file. Then you don't need to worry about what is
    and is not in %ENV and don't need PerlPassEnv (or PerlSetEnv) statements at all.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue Guest

  8. #7

    Default Re: mod_perl and access to the parent processes environment?

    Well lets say that you have any number of servers sharing the same set
    of files. exception configuration. You still need to know how to
    include this host specific file unless you expect it to be only used by
    one server at any given time.

    Assume ServerRoot is the same for all servers.

    Big and Blue wrote:
    > [email]robert.nicholson@gmail.com[/email] wrote:
    > >
    > > Yes the general idea is that I set the environment up with the host
    > > specific info or at the very least hostname of the server i'm starting
    > > and then pull that out of %ENV later. Now I know I can use
    > > getbyhostname in a <perl> block but I wanted to know if my <Perl>
    > > stanza should be able to pull out of %ENV anything that I've
    > > PerlPassEnv'd. Because when I tried this it doesn't work.
    >
    > As I mentioned before, you can always get a script, run at startup, to
    > do anything you want ie: the startup script does a gethostbyname() call and
    > writes the result into an Apache config file which you then include into
    > your static Apache config file. Then you don't need to worry about what is
    > and is not in %ENV and don't need PerlPassEnv (or PerlSetEnv) statements at all.
    >
    >
    > --
    > Just because I've written it doesn't mean that
    > either you or I have to believe it.
    robert.nicholson@gmail.com Guest

  9. #8

    Default Re: mod_perl and access to the parent processes environment?

    On 07/22/2006 01:15 AM, [email]robert.nicholson@gmail.com[/email] wrote:
    > Yes the general idea is that I set the environment up with
    > the host specific info or at the very least hostname of the
    > server i'm starting and then pull that out of %ENV later.
    > Now I know I can use getbyhostname in a <perl> block but I
    > wanted to know if my <Perl> stanza should be able to pull
    > out of %ENV anything that I've PerlPassEnv'd. Because when
    > I tried this it doesn't work.
    > [...]
    And I didn't work when I tried it. From what I can tell, very
    little of the environment is available within <Perl> sections.
    As an alternative, you can probably place your configuration
    in an external config file, such as /var/wwwconfig/config.pl.
    Then in your <Perl> section, you could execute it using "do" e.g.:

    /var/wwwconfig/config.pl:
    $Port = 8080;

    /etc/apache2/httpd.conf:
    ....
    <Perl>
    do '/var/wwwconfig/config.pl';
    </Perl>


    HTH

    Mumia W. Guest

  10. #9

    Default Re: mod_perl and access to the parent processes environment?

    [email]robert.nicholson@gmail.com[/email] wrote:
    >
    > Well lets say that you have any number of servers sharing the same set
    > of files. exception configuration. You still need to know how to
    > include this host specific file unless you expect it to be only used by
    > one server at any given time.
    I'll assume that by "any number of servers" you mean different instances
    of httpd running.

    That means each of them has a separate startup script somewhere along
    the startup path, and that one can create, on the fly, the relevant include
    file to be included by a static name. The rest of the config file(s) can
    be shared.



    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139