Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apache2 Virtual Hosts question

Multiple Header Identities on a Virtual Host



12:40 pm on Nov 9, 2012 (gmt 0)

Greetings all ...

I am currently moving a website from Microsoft IIS v7 onto Apache2 v5.5 under a Debian variant. There will be several different Virtual Hosts. Everything is basically working but I need a little advice:

IIS7 has an option which permits entry of a list of possible Host/Server Name/Identity submissions which may be received for any given specified Virtual Host.
For example:
might all have to point to the same content on the web server.

So, to the point: what is the simplest and most effective method of achieving this in Apache2?

Incidentally, I am using Webmin 1.6 to manage the server applications on the Debian machine.

Many thanks,

Kenneth Spencer


1:07 pm on Nov 9, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

welcome to WebmasterWorld, Kenneth!

i'm not sure what v5.5 is but your apache should be a version of 2.0, 2.2 or 2.4 - but this shouldn't matter as far as your question is concerned.

within your <VirtualHost> context you would typically set your hostname for the virtual host using the ServerName directive.
you can also specify one or more alternate hostnames within that <VirtualHost> context using the ServerAlias directive.

if you do this you should pick one of those hostnames to be the canonical hostname and 301 redirect all non-canonical URLs requested to the canonical hostname.

Name-based Virtual Host Support - Apache HTTP Server:
http://httpd.apache.org/docs/current/vhosts/name-based.html [httpd.apache.org]

<VirtualHost> Directive:

ServerName Directive:

ServerAlias Directive:


4:58 pm on Nov 9, 2012 (gmt 0)

Thanks alot for that speedy reply, ph.

And sorry about the v5.5 I think that's the MySQL version! Apache2 is indeed v2.2.22.

I shall try the ServerAlias directive early next week, but I think that seems to replicate what I needed.

All the best

Kenneth Spencer


6:49 pm on Nov 13, 2012 (gmt 0)

Thanks again for the earlier reply.

I have done a some more work on the server, but I still haven't got it right. So here is some more background:

1. Background
I have a subdomain on an external dynamic DNS service of the form:
I do not own example.com, and the subdomain my-example is provided by the DNS service as part of my subscription. (I have several of them).
The my-example.example.com points to my WAN IP address and is directed to my web server by local IP address and port 80 redirection in my router.
This is for background only as all this is working on the existing server.

2. Default website (Working)
On the Apache2 web server I wish to use the root-data directory /var/www as the default website.
The web server is registered in my DNS Server in the form:
[my-serverIP] my-machine-name
and is thus accessible from my LAN as:
or as:
As there in only one local domain on my LAN, I do not need to fully qualify the address.

2. First Virtual Host
The data for the my-example web site is in a subdirectory /var/www/my-example and thus at the moment can be accessed as:
or as:
This is working, but I need to set up access as:

I have tried several different arrangements for the entry in /etc/apache2/sites-available/my-example but none so far have worked properly.
My ports.conf file contains:
Listen 80
and some other lines relevant to SSL port 443.

In /etc/apache2/conf.d I have a file ServerName.conf which contains the line:
ServerName my-machine-name

Also in /etc/apache2/conf.d I have a file VirtualHosts.conf which contains the line:
NameVirtualHost [my-serverIP]:80

So far, Apache2 starts and stops with neither warning nor error, and the default website and my-example site are available as stated in 2. and 3. above.

In /etc/apache2/sites_available I have a file my-example which contains the following lines:
<VirtualHost my-example:80>
ServerAdmin [email address]
ServerName my-example
ServerAlias www.my-example.example.com
ServerAlias *.my-example.example.com

DirectoryIndex index.htm
DocumentRoot /var/www/my-example

ErrorLog /var/www/my-example/logs/error.log
CustomLog /var/www/my-example/logs/access.log combined

When I link this file into /etc/apache2/sites-enabled and start Apache2 I receive the error:
"Starting web server Apache2 [date] [error] (EA1 2) Name or service not known: Could not resolve host name my-example -- ignoring!
Action 'start' failed.
There is no error.log in /var/www/my-example/log but there is an error in /var/log/apache2/error.log:
"[Date] [notice] caught SIGTERM, shutting down.
[Date] [notice] seg fault or similar nasty error detected in the parent process

Perhaps I am missing an obvious error?

Sorry about the long post but I thought you'd appreciate as many details as possible.

Thanks in advance,

Kenneth Spencer


10:20 pm on Nov 13, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

what happens when you do this?

nslookup my-example


12:48 am on Nov 14, 2012 (gmt 0)

If I do an nslookup on a remote (Windows) PC it finds my-example.my-domain.local, as the web server machine is in the DNS on my LAN. In fact it is in my DNS as the machine name and per the entry in the virtual hosts.

However, the web server machine doesn't have nslookup (and I cannot find it from any of my known sources) so I cannot try it from the web server machine. In the web server, the ServerName is definitely in the /etc/hosts file.

Thanks for the reply ...

Kenneth Spencer


2:26 am on Nov 14, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Could not resolve host name my-example

you need to do the nslookup from the server.
i can't imagine nslookup is unavailable.
what type of system is your server running on?

"nslookup my-example" should resolve to an IP address.

you could also try:

ping my-example


9:47 am on Nov 14, 2012 (gmt 0)

Thanks PH ...

Indeed I should have stated previously that:
ping my-example
correctly gets replies. So it does resolve outside Apache2. But maybe Apache2's error message is misleading.

Regarding nslookup: I am running Debian Wheezy 7.0.
So far as Debian is concerned, nslookup is part of BIND and all the indications are that it cannot be installed alone. I don't wish to install BIND as I already have a DNS server on my Windows 2003 R2 domain controller.

The machine name, and all virtual host names are entered into the /etc/hosts file (because ultimately I am intending to run this machine as a standalone web server) so far as direct access on the local machine is concerned.

I have a couple of other things I will try, but what I need to avoid is a repeat of what has already happened - namely that the server became quite "messed up" and reinstalling packages didn't sort it out, so I had to reinstall the lot: OS, Proftp, Apache2, Webalizer, MySQL, PHP5 etc etc etc!

Thanks again for your attention.



11:27 am on Nov 14, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

<VirtualHost my-example:80>

try using the IP address instead of the hostname in the VirtualHost directive:
for example:



5:18 pm on Nov 15, 2012 (gmt 0)

Thanks PH ...

I had previously tried using the IP address of the server instead of the hostname. And having tried it again, it still fails.

I don't know why Apache2 collapses with a SIGTERM when I am certain the the configuration is correct. And even if it wasn't I'd have thought that any error should be trapped.

It's a bit disappointing, but I am going to re-install the OS and Apache2 in a minimal server so that re-installation of the whole thing during the discovery of why this isn't working is easier. If I can then get a set of configuration files that work (!) I will try them with a fully installed fully configured server.

You may not hear from me for a while but thanks for your patience!

Best wishes,



11:57 pm on Nov 15, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

try testing the apache configuration with:

apachectl configtest


apachectl -t


9:51 am on Nov 16, 2012 (gmt 0)

Hello again, PH ...

Last night I completed a detailed look at what I was trying to do with Apache2, but using an absolutely minimal installation of the OS and of Apache2.

I am glad to say that I made progress. I will probably not be able to do much more now until Tuesday of next week as social things will get in the way of web development. However, it seems that there are some things concerning the log files which Apache2 is unable to trap if they are not quite right - they are the cause of the SIGTERMs.

On Tuesday I shall complete the tests on the minimal installation and then try to implement my changes on a full system (possible after a full re-installation of absolutely everything because I suspect that the existing full installation may have been damaged by the events).

I will report back after that.

Many thanks again for your interest and help ...


Featured Threads

Hot Threads This Week

Hot Threads This Month