?
Solved

config option that's visible to PHP?

Posted on 2006-04-05
8
Medium Priority
?
165 Views
Last Modified: 2010-05-18
I have a staging server and a live server, and I run the same code base on both... there's some directives in the PHP to change paths, etc, if it's running on staging. But for that to work, the PHP Script has to be able to ID the machine it's on. (I prefer this to setting a flag every time I want to move the code from staging to live.)

I tried using  "if(stristr($_SERVER['HTTP_HOST'], 'localhost'))" which works (since my local apache that I use for testing is just http://localhost)... except I run it on a couple of different staging servers that both resolve as localhost.

Is there some minor Apache option I could set, that would be retrievable in PHP?

(I say minor, since I could probably change 'localhost' to something more machine-specific, but I'd prefer not to. Ideally, it'd be some kind of minor PHP flag I could set in the httpd.conf file, then PHP could just check that.)

thanks-
Eric


0
Comment
Question by:pnoeric
7 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 16390171
> it'd be some kind of minor PHP flag I could set in the httpd.conf file, then PHP could just check that.

You might set an apache ENV

SetEnv local 1

should make the ENV 'local' available containing the value 1
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16390639
how about using $_SERVER['SERVER_NAME'] or $_SERVER['SERVER_ADDR']
0
 

Author Comment

by:pnoeric
ID: 16513324
unfortunately, the 'SetEnv' didn't work-- I added it but it never showed up in phpinfo() or $_ENV or $_SERVER.

I ended up using $_ENV['computername'].

thx
E
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:pnoeric
ID: 16513327
(this question can be closed, with no answer)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16519738
> I ended up using $_ENV['computername'].
what doies this mean? Apache has no environment variable computername
0
 

Author Comment

by:pnoeric
ID: 16519857
hmm, it showed up in my apache config-- you know, it might be because I'm using this on my local environment, which is a windows pc. it's fine if my staging and dev servers (both linux) don't have computername, since the test will just fall through.
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16715756
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question