Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to retrieve the ServerName field located in /etc/apache2/apache2.conf. My only issue is then calling it in PHP (echo $_SERVER['SERVER_NAME'];) it gives me not the server name but the ip address.

If I pull a phpinfo(); I can the server name under the Hostname:Port field under the apache2handler, so I know it's accessible somehow.

share|improve this question
If you can not find it in $_SERVER['HTTP_SERVER_NAME'] perhaps consider that your Apache2/PHP configuration is not 'right'. – JavaRocky May 1 '10 at 3:08
But it shows up in phpinfo(), it can be found there somewhere. – Josh K May 1 '10 at 3:11
up vote 1 down vote accepted

In PHP do a


or even


Should help you. I have a feeling it is probably $_SERVER['HTTP_SERVER_NAME'] but do the above and it will tell you exactly

share|improve this answer
It's not in $_SERVER at all, I'll check $_REQUEST. – Josh K May 1 '10 at 3:02
Nope, nothing there either. This is similar to this other question I found but the answer is unclear. – Josh K May 1 '10 at 3:03
And you can't use HTTP_HOST? – Wizzard May 1 '10 at 3:32
In your phpinfo() output scroll downto "Apache Environment" section, is there anything in there? – Wizzard May 1 '10 at 3:34
Yeah, fixed it. Had something to do with UseConicalName or something. – Josh K May 1 '10 at 4:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.