do i need an apache servername setup?
Asked Answered
N

1

6

I'm no really sure if SO is the place to ask this question - let me know if not. I thought about superuser, but it didn't seem to fit into their faq specs much.

Anyway - the question! Do i need to put in the ServerName value in my apache2.conf file if i'm just using the server to service a single website? If so, what should i set it to?

I'm following this guide:

http://meppum.com/2009/jan/17/installing-django-ubuntu-intrepid/

and it suggests i set the "SeverName" setting in my apache2.conf file. I checked about and found this article, that discusses "ServerName"

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:Ch20:_The_Apache_Web_Server

Which is interesting and all, but it doesn't really tell me when i need to set the ServerName. 'Far as i can judge, i only need it when i'm doing some sort of something.domainname.com, like, say, answers.yahoo.com

Is this the case? If not, what is servername (for, say, a domain called www.yahoo.com at, say, 192.0.0.1) meant to be?

Nagoya answered 1/7, 2012 at 2:46 Comment(0)
A
5

If the server is hosting a single website, you don't have to use VirtualHosts, so you don't have to define ServerName, however it's recommended to do it.

If you don't do it, Apache will try to find out the hostname based on the server IP performing a reverse DNS lookup.

From the Apache documentation:

The ServerName directive sets the request scheme, hostname and port that the server uses to identify itself. This is used when creating redirection URLs.

Additionally, ServerName is used (possibly in conjunction with ServerAlias) to uniquely identify a virtual host, when using name-based virtual hosts.

For example, if the name of the machine hosting the web server is simple.example.com, but the machine also has the DNS alias www.example.com and you wish the web server to be so identified, the following directive should be used:

 ServerName www.example.com

ServerName www.example.com If no ServerName is specified, then the server attempts to deduce the hostname by performing a reverse lookup on the IP address. If no port is specified in the ServerName, then the server will use the port from the incoming request. For optimal reliability and predictability, you should specify an explicit hostname and port using the ServerName directive.

Answering your questions:

Do i need to put in the ServerName value in my apache2.conf file if i'm just using the server to service a single website?

No, you don't, but it's recommended.

If so, what should i set it to?

The syntax is : ServerName [scheme://]fully-qualified-domain-name[:port]

Is this the case?

No, not only.

If not, what is servername (for, say, a domain called www.yahoo.com at, say, 192.0.0.1) meant to be?

ServerName www.yahoo.com

Adjoint answered 28/4, 2014 at 10:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.