#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    425
    Rep Power
    0

    Naming a server, via environment variable


    I have several servers, and similar versions of the same code running on each of them.

    I would like to be able to place a custom environment variable on each server, either in the php.ini or httpd.conf, and be able to read it via one of the environment variables, like $_SERVER, $_ENV

    The value might be something like "APP01", "APP02" etc, to define the PHYSICAL server.

    I could do this via IP address, but then I would have to keep a list of all IP addresses and what servers they match.

    Thank you for any assistance, in advance!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    425
    Rep Power
    0
    I found my own solution...

    mod_env is installed on the server.

    I added:
    SetEnv HTTP_MY_HOST "app01"
    to the http.conf

    I can now read this as $_ENV['HTTP_MY_HOST']

    I found it VERY important to begin the name with HTTP_ because otherwise suexec scrubed the variable.

    Comments on this post

    • paulh1983 agrees : thanks for letting us know...
    • ManiacDan agrees

IMN logo majestic logo threadwatch logo seochat tools logo