Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 1 down vote accepted

In PHP do a

var_dump($_SERVER);

or even

var_dump($_REQUEST);

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

 
discard

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.