<VirtualHost 127.0.0.1>
ServerName mail.127.0.0.1
DocumentRoot apache\vhost\mail
ServerAlias mail
</VirtualHost>
What's wrong? When I go to my site it works fine but going to
mail.localhost does not take me to that document root.
I read the article and got the information from there.
Rune
01-28-2003, 03:26 PM
localhost is defined in your HOSTS file, but Apache's conf file will treat domain names and IP's differently. (I just went through this nightmare earlier this week. ;))
First of all, not sure what OS your running but if it's Windows you need to change the paths to show quote marks and the full path with drive letter (shown below).
Second of all, make sure your NameVirtualHost and VirtualHost are both an "*" as below, no IP and ESPECIALLY no domain name ( sorry, had those backwards - fixed).
... and keep in mind that it'll check the FIRST VirtualHost in the list first for a match. So if these host blocks were switched "*.mydomain.name" would catch all the "mail.mydomain.name" requests (since "*" is a wildcard) and serve them, not even letting the request get to the "mail.mydomain.com" VirtualHost block (found this out after much frustration ;)). If a request doesn't match the first, it'll go on to the second, then third, etc. If it doesn't find a match at all it'll go back and use the first one by default. SO make sure the first one is a generic or a page you don't mind EVERYONE seeing ... just in case. ;)
This is why on mine, I have www.mydomain.com going one place, forum.mydomain.com going another place, PLUS I'm hosting 3 different domains. ;) So I need 6 VirtualHost blocks, to redirect 6 different domain names to 6 different root (sub) folders, PLUS I use one generic "catch all" to precede them and be a defualt so in case something goes wrong, they'll get forwarded to a generic "OOPS!" page in my main root folder. ;) This is mine (note: the "mydomain1", "mydomain2", etc in the root paths are subfolders in my htdocs folder) :
>> Since this is my virst virtual host, does this affect any other settings within my apache? What about the logs? All I see is document root and nothing more. And I guess you can't use any ip or localhost.. it has to have a name right?
How can I let the server know that's another virtual host, a second one? Remember it's all on the same IP.
Is this correct? Virtual Hosts have to have a name, they can't be IP numbers or localhost
If any of my writing is confusing... please let me know. Thanks
Rune
01-29-2003, 03:24 AM
Originally posted by JoeBoard
Since this is my virst virtual host, does this affect any other settings within my apache?
Yes, whatever lines you put in your VirtualHost containers, they'll be used - Apache will thereafter ignore whatever you have in the Global Settings, Section 2 higher up in the conf file (such as ServerName, DocumentRoot, ServerAlias, ErrorLog, etc.) Whatever you DON'T put in the VirtualHost containers (for example if you don't specify a different error log location in the VIrtualHost container) it'll just use whatever you have set in the Global settings.
What about the logs? All I see is document root and nothing more.
You mean you want to specify different logs for each VirtualHost? Sure, just add whichever of these lines, or both to your VirtualHost block(s) (ie you might want one access log for the whole server (as is by default) but maybe seperate error logs for each one, or vice versa, or both, or neither :)) and change the path to where ya want the logs to go. Note: I have no idea what the "common" part of the last line is for. :o :
ErrorLog "C:/Apache/logs/error_log"
CustomLog "C:/Apache/logs/access_log" common
And I guess you can't use any ip or localhost.. it has to have a name right?
It's usually best just to leave it as a "*" ... seems to avoid alot of problems, but you CAN specify your IP if you want (sorry, had that backwards earlier). Problem is that the VirtualHost blocks basically look for a specific URL request. If your IP is 111.222.33.44 and someone types the address http://111.222.33.44/ ... in their browser ... it'll work fine. But if someone types in your domain name (http://www.yourdomainname.com) which is set to forward to the IP 111.222.33.44 ... it may not work (I honestly haven't figured out all the ins and outs of "why"). Safest usually just to leave it to "*". I've tried several other methods (even specifying the one IP in each VirtualHost block but giving it a different port each block) ... it was a nightmare. Wouldn't get to the right page or all three domains were going to ONE page, etc. yech.
Then I tried to make a second one, this is where it failed...
How can I let the server know that's another virtual host, a second one? Remember it's all on the same IP.
Do you have a domain name or are you just using an IP address for your URL? If you do have a domain name registered, you may have to do what I did (it was the last thing on my troubles list and I finally got it working ... just yesterday :D). Go to the site where you can administer your domain name settings and check your Hostnames A-records (If by some coincidence you're with the same folks as I am - Domain Direct - ya just go into "Advanced Domain Settings", then "Edit Zone File". My A-Records were pointing to an IP at the domain server, so hits to my server were basically looping through the domain server TWICE (slowing it down) and messing up the reference for Apache since the reference had now been "forwarded" by my domain, not just sent straight through. Change those settings to your IP. If you have a blank to ADD another Hostname, best to add your "fs.mydomain. ..." one to it as well. In fact here you can see one of mine:
http://www.stephenqr.com/misc/frustration3.jpg
Three of those were there already, I just had to change the IP to point to MY server IP. The fourth one, "forum. ... " I added myself, so it treats it like it's own seperate domain name. This is kinda like "Domain Forwarding" without the middle man ... er, middle server. ;)
Easiest thing for me to remember when dealing with VirtualHosts is that they are basically server request checkpoints. When a request comes in, wether it be for http://www.mydomain1.com or http://www.mydomain2.com or http://mydomain1.com/pictures/hawaii_trip.html ... Apache will run that domain requested through the Virtual Host blocks form top to bottom. If it matches the ServerName or ServerAliases in the first VirtualHost block, it ships the request off to the DirectoryRoot specified in that VirtualHost block. If it doesn't match the ServerName or ServerAliases, it'll try to run it through the SECOND VirtualHost block and so on. If it can't find a match in any of 'em, it'll run it back to the first VirtualHost block and just go to that DirectoryRoot by default. And keep the first "generic" VirtualHost block as bare as possible as you have it (ie NO ServerName, NO ServerAlias, etc) so it will never "match" a request ... it'll only be used as the LAST case resort for Apache to go to like a safety net. You can do without this generic VirtualHost block of course, but keep in mind that whatever would THEN be the "first" VirtualHost block - THAT will now be the default. In cases like mine, I have to be careful what I have as my first block because I don't want visitors to one domain to accidentally get forwarded to one of the others. :o
[edit] Oh, and on a side note - don't forget that some setting changes on your domain hosts admin site take quite awhile to be implemented (some of mine say 3-4 hours), so if you make a change and it doesn't appear to work ... it may be the right settings, they just haven't been applied at the domain host's site yet. I had the "correct" settings probably a dozen times but kept changing them again cuz I forgot this little tidbit. :D)
JoeBoard
01-29-2003, 08:41 AM
Hello Rune,
Thanks for continuing to assist me with Virtual Hosts. I read your information, and that's a long response :)
First I'd like to point out I'm using a service called Dynu as my domain host. I have a subdomain provided by Dynu DNS Services [dynu.com]
You told me to look at some so called "A-Settings" I don't think I have that option with Dynu.
****
Now, to your first point about the vhosts overriding everything. I have set alias, and index settings for many folders, when I setup my first virtual host, will this effect any of those settings?
Apache as default crates logs, do I just add the log commands to that code, like you said?
****
Now, to the second point. I won't use IPs then, but that means I always have to use my domain and I can't access my subdomains via mail.localhost or fs.localhost right? I'll always have to use something like http://mail.joe.dynu.com
The first virtual host is the mail directory right? This works fine, the second virtual host works too, and takes me to the mail. Then the third does not work anymore. It does not take me to the forums folder, like the second mail one. Do you happen to know why this is? If you explained it in your last post... I did not catch that.
****
I don't have any domain settings I can make, well that's not completly true... there are many settings at dynu.com I can make, but I have not seen anywhere you can add subdomains like yours - but I'm sure it's possible.
****
Do you have any messenger (ICQ, AIM, YAHOO, etc) ?
Forums are great, but maybe we can chat via a messenger, so you can take a look at my server and setups directly.
Best Regards,
Joe
Rune
01-29-2003, 12:41 PM
Originally posted by JoeBoard
You told me to look at some so called "A-Settings" I don't think I have that option with Dynu.
No "Hostname A-Record" settings you can change? That's wierd, if you pay for a domain name they should give you a way to change that. Might want to check Dynu's FAQ or even email them and find out - I don't see why any domain host would deprive you of that option.
Hmm ... I just went to Dynu to look around in their FAQ and what-not. I don't know if they give you the option or not. They mention domain forwarding, but that's not quite the same thing. Plus it sounds like they're for when you have a dynamic IP and want their software to auto-detect it and make the changes automatically. So it's hard to tell - they may be updating the A-Record names automatically, then again they may only be updating domain forwarding. If I'm guessing right, you probably have some software from them on your computer doing this, right? If so, you may want to check in there for some answers - ie does it update domain forwarding settings or A-Record name settings, can you do it, how do you do it, etc.
Is your computer always on and your connection pretty stable? If so, even with a dynamic IP you may be able to get by without any "auto dynamic IP updating" software (though I'm not sure if this software is a "requirement" of Dynu's or not). I've had 2 ISP's that claim "Dynamic IP", but truth be told, as long as your connection is (fairly) ever-present, the odds on your IP changing are slim. Usually the only time my IP changes is when my power goes out (and subsequently my connection to the ISP) for a long period. But typically your computer will attempt to refresh the lease on the same IP you had before. As long as no one else logged on and coincidentally snatched it while you were disconnected ... you'll usually get the same IP back.
In the end, if you can't change your A-Record names, it'll still work ... it's just canonical name might not. (ie when someone types in your domain, it may change it to http://111.222.33.44/ ..." and you won't be able to get "http://www.mydomain.com" to stay in the browser address bar.)
Now, to your first point about the vhosts overriding everything. I have set alias, and index settings for many folders, when I setup my first virtual host, will this effect any of those settings?
THIS block, as is ... no. Only time VirtualHost settings will override the global settings is when you specify them explicitly. In a way, VirtualHost blocks are like mini-Apaches. ;) Each VirtualHost block has it's own ServerName, ServerAlias, DocumentRoot, log files, etc. Whatever you specify in a VirtualHost block, it'll use. Whatever you DON'T specify in a VirtualHost block, it'll just invisibly fill inthe blanks with the default global settings. For example, the above block could be seen like this (italicized parts are actually "invisible" to you in the conf file):
Apache as default crates logs, do I just add the log commands to that code, like you said?
If you want any/all your VirtualHost blocks to use different logs, yes. If not just leave those lines out and Apache will save the log files where it normally would by default.
Now, to the second point. I won't use IPs then, but that means I always have to use my domain and I can't access my subdomains via mail.localhost or fs.localhost right? I'll always have to use something like http://mail.joe.dynu.com
Are you saying you literally want to type in "localhost"? If so ... hmmm ... not QUITE sure how to do that, but you could try adding to the "ServerAlias" and do something like this:
... or if that doesn't work, try "127.0.0.1" in place of "localhost". No idea if this'll work or not. If it does, obviously it'll only work for YOU to access it from your own computer.
The first virtual host is the mail directory right? This works fine, the second virtual host works too, and takes me to the mail. Then the third does not work anymore. It does not take me to the forums folder, like the second mail one. Do you happen to know why this is? If you explained it in your last post... I did not catch that.
****
I don't have any domain settings I can make, well that's not completly true... there are many settings at dynu.com I can make, but I have not seen anywhere you can add subdomains like yours - but I'm sure it's possible.
Do you have to have it as "forums.dynu.net" or does it need to be "forums.name.dynu.net"? I noticed the "name" part of the mail one and wasn't sure if that needed to be in the forums one too. Otherwise, check Dynu's settings (if you can't change your A-Record Name settings, check your domain forwarding settings) and make sure that "forums.dynu.net" is set to forward to your Apache server (your IP).
Gonna be leaving shortly, but I'll be around later this afternoon. Good luck!
JoeBoard
01-29-2003, 01:08 PM
:) ok... let's see now.
Dynu has MX Settings, but that not what we want right?
I believe MX Settings refer to Mail Servers, but I'm not sure.
I'm forgetting about localhost, I'll just have to use my Dynu domain. localhost does not work with virtual hosts, you have to have a domain, not even the IP.
I don't understand why
mail.mydomain.dynu.com works
and
forums.mydomain.dynu.com does not work.
It's the same setup! Any ideas?
I'm still searching for more options, I hope I can get this working... at least one virtual host is working.
Rune
01-29-2003, 02:57 PM
Yeah, MX settings are different. That's if you want to host your own smtp/pop3 server. I've tried that, Win2k comes with a simple smtp server, but no pop3 server. And the only pop3 servers out there are either "one user only" or hella expensive. But anyhoo ...
... and the "mail.name.dynu.net" one is working and the "forums.dynu.net" one isn't? ... and you're SURE that the mail one is working? I mean if you went to h:/apache/vhost/mail manually you'd get a different page then if you went to h:/apache/htdocs ? Hmm ... well if so, that's a good thing, cuz then at least you know that the first two VirtualHost containers ARE working (if it wasn't, it'd go to the first "generic" VirtualHost block). And you're positive that the DocumentRoot is correct and there aren't any "spelling" errors or anything like that?
I assume the "name" part of the first one (mail.name.dynu.net) is actually your domain name? Have you tried using "forums.name.dynu.net" in that block that's not working?
JoeBoard
01-29-2003, 10:19 PM
Well, I think we are heading to the end of this thred now... at least if it's true what I found out.
I was looking at my Dynu today, and noticed you have to be paying for extra so called "alias" is that what I think it is? The mail alias is free (mail.yourdomain.dynu.com) but not the rest? Or is this for something else. I have sent them a mail, but I'm still awaiting a response.
I'll keep you posted.
I agree, there is no good mail server out there, at least for Windows that is free... and supports unlimited users. That however has changed, I just got DeskNow (www.desknow.com) and so far am very pleased with it. It's a mail and discussion forum... you may want to check it out. (runs with Apache)
Rune
01-29-2003, 10:55 PM
Not sure what they call "Alias" but if it is what you're thinking ... that just sucks. Sorry to hear that. Not sure if it's an option, but ya may wanna consider transferring your domain hosting to another host.
Only one I can vouch for is Domain Direct ... I've had them for 3 years and other than their admin page being a little on the slow side ... their domain name hosting has been seamless and they let you control every setting yourself ... including the ones that can render your domain broken (but there's plenty of warnings). :D
Good luck, hope you get it. :)
JoeBoard
01-30-2003, 09:07 AM
:( I got an e-mail response and here is what it said:
Dynu Basic cannot support subdomains but our dynu premium services > provides any number of subdomains for your primary domain so you can register premium services at http://www.dynu.com/premium.asp.
I guess I have to pay to have subdomains. I want to apoligze having you go through all the information for nothing, but I learnt a lot and if I decide to buy the premium I know how to do it! :)
Rune
01-30-2003, 09:17 AM
No problem. :)
I'd still check into what they mean by "subdomains" ... that might still be domain forwarding. Ask 'em flat-out if the premium package gives you access to your CName and A-Records, etc. Also at how much. Worse comes to worst I'd consider transferring to another host.
But good luck with it either way. :)
JoeBoard
01-30-2003, 09:38 AM
Take a look at this site... (http://www.dynu.com/iishelp.asp) it tells you about: "How can I host multiple websites using one IP address on Windows NT/2000 IIS server?"
I'm not sure if that's what I want-- but that is free. Is that also like virtual hosts? It's for IIS but to me that looks like virtual hosting.
In regards to the mail, I pretty much explained them exactly what I wanted to do, but they told me that was not possible. I'm sure there was no misunderstanding.
Dynu.com is not a bad service, I've been with them quite sometime. Too bad I can't get those subdomains though. :p
Rune
01-30-2003, 09:50 AM
Originally posted by JoeBoard
Take a look at this site... (http://www.dynu.com/iishelp.asp) it tells you about: "How can I host multiple websites using one IP address on Windows NT/2000 IIS server?"
I'm not sure if that's what I want-- but that is free. Is that also like virtual hosts? It's for IIS but to me that looks like virtual hosting.
Sure looks that way to me, too. That is IIS's version of "Virtual Hosting" .... wierd that Dynu doesn't allow you to access your Zone File settings (A-Records, CName, etc) or forward a subdomain though.
If their premium service allows subdomains and subdomain forwarding you can probably do it that way and achieve the same desired results. One thing that I mentioned before though - "Domain forwarding" your subdomains as opposed to "altering the A-Records" may not keep their canonical name in the address bar. ie when someone visits forums.mydomain.com it may resolve to "http://111.222.33.44/ ..." and lose the prettier domain name in the address bar. But if this isn't a biggie for ya ... *shrug*
But I'd hate to recommend ya to go for it and upgrade service and then find out that there's some other snaffoo that won't let ya do it, though. :D ;)
JoeBoard
01-30-2003, 11:20 AM
Hello Rune,
Yeah... the thing about IIS and Apache is strange. I'll e-mail them and ask them what the IIS thing is, compared to the subdomains, maybe they are talking about something else or we are talking beside each other. :D
I'll post when I get the next reply.
Serverwatch.com
Copyright Internet.com Inc. All Rights Reserved.