Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do i need an apache servername setup?

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?

like image 840
bharal Avatar asked Jul 01 '12 02:07

bharal


People also ask

What is ServerName in Apache configuration?

ServerName - If the host part of the HTTP request matches this name, then allow the request. Normally this would be a domain name that maps to an IP, but in this case the HTTP request host must match this IP. ServerAlias - Alternate names accepted by the server.

What is the purpose of an Apache virtual host?

A Virtual Host is an Apache configuration directive that allows you to run more than one website on a single server. With Virtual Hosts, you can specify the site document root (the directory containing the website files), create a separate security policy for each site, use different SSL certificates, and much more.

What is the need of Apache server?

As a Web server, Apache is responsible for accepting directory (HTTP) requests from Internet users and sending them their desired information in the form of files and Web pages. Much of the Web's software and code is designed to work along with Apache's features.

What is ServerName in virtual host?

As described in Documentation ServerName shows the hostname and port the server uses to identify itself while ServerAlias gives alternate names for a host used when matching requests to name-virtual hosts. In name-based virtual hosts the hostname is specified by the request's Host header.


1 Answers

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

like image 91
Céline Aussourd Avatar answered Oct 11 '22 16:10

Céline Aussourd