View previous topic :: View next topic |
Author |
Message |
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Thu Aug 23, 2007 8:13 pm Post subject: server name on Windows XP |
|
|
Where does Abyss/php pick up the server name in Windows XP? The machine I am using has a name and a workgroup as is normal for Windows XP.
When I run a php script, I get nothing back for $_SERVER['SERVER_NAME'].
I recall a message when I installed Abyss, about it not being able to establish the server name.
Strangely, I can get it in perl, using `hostname`. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Aug 23, 2007 8:17 pm Post subject: |
|
|
Try this:
Code: | <?php
// Prints out localhost, if requested from localhost
echo $_SERVER['SERVER_NAME'];
?> |
|
|
Back to top |
|
|
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Fri Aug 24, 2007 7:00 pm Post subject: I did try that |
|
|
Thanks for the suggestion - that is exactly what I had been using with incorrect results.
I was misleading in my original post.
$_SERVER['SERVER_NAME'] returns the ip address of the machine.
$_SERVER['SERVER_ADDR'] returns nothing. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Aug 24, 2007 7:17 pm Post subject: |
|
|
The first variable listed returns the same value as the HTTP_HOST variable or the name of the server. In Abyss's case, the Hostname.
The second variable is not available in Abyss Web Server because of Hostname lookups not being supported. You can get the Server's IP Address, using a simple function.
Code: | <?php
// Recreate the $_SERVER['SERVER_ADDR'] variable, using the gethostbyname() function.
$_SERVER['SERVER_ADDR'] = gethostbyname($_SERVER['HTTP_HOST']);
// Now we will output the Server's IP Address:
echo $_SERVER['SERVER_ADDR'];
?> |
|
|
Back to top |
|
|
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Mon Aug 27, 2007 3:52 pm Post subject: Still confused |
|
|
My problem is that these variables do not return what they are meant to return.
$_SERVER['SERVER_NAME'] returns the IP address.
$_SERVER['HTTP_HOST'] returns an empty string
So my tentative conclusion is that Abyss doesn't have the hostname. Why not? Where can I look for it, or change it? |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Mon Aug 27, 2007 4:18 pm Post subject: |
|
|
You're probably accessing your website using a cloaked web address. Are you sure your domain is directly pointing to your IP Address and not hiding in a frame? To check, view the page source of your website. Your IP will only show as the Hostname if your domain isn't properly setup, using an A or CNAME record.
It would help if you just posted the domain address. |
|
Back to top |
|
|
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Mon Aug 27, 2007 4:56 pm Post subject: As usual, I never give the full info |
|
|
I am accessing the webserver only over the LAN using the ip address or localhost, so no domain is involved, or any cloaking of any kind.
The machine has a name that is used in the Windows networking, and I was assuming that name could be picked up by the SERVER_NAME variable. Maybe I'm wrong. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Mon Aug 27, 2007 10:14 pm Post subject: |
|
|
I don't know how it could not be working. What version of PHP are you using? It may also help you posted the PHP script. |
|
Back to top |
|
|
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Tue Aug 28, 2007 3:55 pm Post subject: Script and outpur |
|
|
I am using php5, the version provided with the Abyss web server.
The script is very simple:
Code: |
<html>
<title>
<?php
echo $_SERVER['SERVER_ADDR'];
echo ' - ';
echo $_SERVER['SERVER_NAME'];
?>
</title>
<body>
<h2>
<?php
print $_SERVER['SERVER_ADDR'];
print ' - ';
print $_SERVER['SERVER_NAME'];
print ' - ';
print $_SERVER['HTTP_HOST'];
?>
</h2>
...lots of html
|
And the output:
Code: |
<html>
<title>
- 192.168.254.250</title>
<body>
<h2>
- 192.168.254.250 - 192.168.254.250</h2>
...lots of html
|
|
|
Back to top |
|
|
ric -
Joined: 20 May 2004 Posts: 15 Location: UK
|
Posted: Wed Aug 29, 2007 2:35 am Post subject: |
|
|
If you are after the machine name then you could use $_SERVER['COMPUTERNAME'] |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Aug 30, 2007 4:31 pm Post subject: Re: server name on Windows XP |
|
|
dormant,
SERVER_NAME is filled with the domain name/IP you have used in the URL when accessing the site.
So if you accessed your site using http://192.168.1.100:8000/page1.html, SERVER_NAME will contain 192.168.1.100.
If you accessed it using http://www.mysite.com/page1.html, SERVER_NAME will contain www.mysite.com.
SERVER_ADDR is not filled in Abyss Web Server as it does not perform DNS lookups. But you can easily get that value using SERVER_NAME (or a DNS lookup if of its value if it is not an IP). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
dormant -
Joined: 23 Aug 2007 Posts: 6
|
Posted: Tue Sep 04, 2007 1:08 pm Post subject: Thanks |
|
|
Thanks for the help and info - I now understand what is going on. |
|
Back to top |
|
|
|