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:
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
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:
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:
and is thus accessible from my LAN 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:
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:
and some other lines relevant to SSL port 443.
In /etc/apache2/conf.d I have a file ServerName.conf which contains the line:
Also in /etc/apache2/conf.d I have a file VirtualHosts.conf which contains the line:
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:
ServerAdmin [email address]
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,
what happens when you do this?
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 ...
|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:
Thanks PH ...
Indeed I should have stated previously that:
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.
try using the IP address instead of the hostname in the VirtualHost directive:
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!
try testing the apache configuration with:
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 ...